Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 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" );
  10.         System.out.print( "Message: " );
  11.         String message = keyboard.nextLine();
  12.  
  13.         System.out.println("How many times do you want it to be displayed? ");
  14.         int nTimes = keyboard.nextInt();
  15.  
  16.         int n = 0;
  17.         while ( n < nTimes )
  18.         {
  19.             System.out.println( (n+1) + ". " + message );
  20.             n++;
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement