MrDoyle

8) Do While Loops

Jan 14th, 2021 (edited)
764
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main{
  4.     public static void main(String[] args){
  5.  
  6.        Scanner scanner = new Scanner(System.in);
  7.  
  8.        System.out.println("Enter a number: ");
  9.  
  10.        int value = scanner.nextInt();
  11.  
  12.        while(value !=5){
  13.            System.out.println("Enter a first number: " );
  14.            value= scanner.nextInt();
  15.        }
  16.  
  17.        System.out.println("Got 5!");
  18.  
  19.        int value2 = 0;
  20.        do {
  21.            System.out.println("Enter a second number: " );
  22.            value2= scanner.nextInt();
  23.  
  24.        }
  25.        while (value2 !=6);
  26.         System.out.println("Got 6!");
  27.  
  28.     }
  29.  
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment