Advertisement
mrScarlett

while Loop

Oct 1st, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class EventLoops{
  4. public static void main (String[] args){
  5. int userInteger;
  6. Scanner userInput = new Scanner(System.in);
  7. System.out.print("Enter an integer Value 0 to quit: ");
  8. //This line is saying while the user does not enter 0 run the code given in the curly brackets.
  9. while ((userInteger = userInput.nextInt()) !=0){
  10. System.out.println("You entered "+userInteger);
  11. }
  12. System.out.println("You have selected to quit");
  13. }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement