Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. /*************************************************
  2. * @author Christian Lau
  3. * MyFirstProgram
  4. * 9/18/19
  5. *
  6. * Description: User input, Displays name and age
  7. ************************************************/
  8. package myfirstprogram;
  9.  
  10. import java.util.Scanner;
  11.  
  12.  
  13.  
  14. public class MyFirstProgram {
  15.  
  16. /**
  17. * @param args the command line arguments
  18. */
  19. public static void main(String[] args) {
  20. String name;
  21. Scanner sc = new Scanner(System.in);
  22.  
  23. System.out.println("Please Enter your name");
  24. name = sc.next();
  25. System.out.println("Please Enter your age");
  26. int age = sc.nextInt();
  27. System.out.printf("Hello %s you are %d years old! %n", name, age);
  28.  
  29.  
  30. // Prints out Message along with name and age
  31. // A comma is used after the quotations.
  32. //It tells print f what to pass through.
  33. //You must do it in chronological order or it will not work.
  34.  
  35. }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement