Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*************************************************
- * @author Christian Lau
- * MyFirstProgram
- * 9/18/19
- *
- * Description: User input, Displays name and age
- ************************************************/
- package myfirstprogram;
- import java.util.Scanner;
- public class MyFirstProgram {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- String name;
- Scanner sc = new Scanner(System.in);
- System.out.println("Please Enter your name");
- name = sc.next();
- System.out.println("Please Enter your age");
- int age = sc.nextInt();
- System.out.printf("Hello %s you are %d years old! %n", name, age);
- // Prints out Message along with name and age
- // A comma is used after the quotations.
- //It tells print f what to pass through.
- //You must do it in chronological order or it will not work.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement