Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class InputLoop
- {
- public static void main(String[] args)
- {
- Scanner in = new Scanner(System.in);
- int number=0;
- System.out.print("Enter an integer or Q to quit: ");
- boolean two = false;
- while (in.hasNextInt())
- {
- number = in.nextInt();
- System.out.println(number);
- if (number == 2)
- {
- two = true;
- }
- System.out.print("Enter an integer or Q to quit: ");
- }
- if (two = true)
- {
- System.out.println("yes");
- }
- else
- {
- System.out.println("no");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement