//package exercise;
import java.util.Scanner;
// @author Min
public class Exercise {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
final int SENTINEL = -1;
int number;
Scanner scan = new Scanner(System.in);
//Scanner() << in () there must be method to use through or exact variable to use
//declaring Scanner object, the name is scan, taking System.in as parameter
System.out.println("Enter an integer, -1 to end");
number = scan.nextInt();
//it calls memberfuntion of scan, it takse nextint
while(number != SENTINEL){
System.out.println(number);
System.out.println("Enter an integer, -1 to end");
number = scan.nextInt();
}
System.out.println("Sentinel vaule detected. goodbye!");
}
}
//Hello JAVA!!! sorry to hate you but let's be friend from now!!
import java.util.Scanner;
// @author Min
public class Exercise {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
final int SENTINEL = -1;
int number;
Scanner scan = new Scanner(System.in);
//Scanner() << in () there must be method to use through or exact variable to use
//declaring Scanner object, the name is scan, taking System.in as parameter
System.out.println("Enter an integer, -1 to end");
number = scan.nextInt();
//it calls memberfuntion of scan, it takse nextint
while(number != SENTINEL){
System.out.println(number);
System.out.println("Enter an integer, -1 to end");
number = scan.nextInt();
}
System.out.println("Sentinel vaule detected. goodbye!");
}
}
//Hello JAVA!!! sorry to hate you but let's be friend from now!!
댓글
댓글 쓰기