Advertisement
MrDoyle

While) Counting with a While Loop

Nov 13th, 2020
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main
  4. {
  5.     public static void main( String[] args )
  6.     {
  7.         Scanner keyboard = new Scanner(System.in);
  8.  
  9.         System.out.println( "Type in a message, and I'll display it" );
  10.         System.out.print( "Message: " );
  11.         String message = keyboard.nextLine();
  12.  
  13.         System.out.println( "How many times would you like me to display the message?" );
  14.         int times = keyboard.nextInt();
  15.         int n = 0;
  16.  
  17.         while ( n < (times*10) )
  18.         {
  19.             System.out.println( (n+10) + ". " + message );
  20.             n=n+10;
  21.         }
  22.  
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement