HarrJ

B8 Day 7 1st code assignment with scanner

Sep 18th, 2022
1,381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. package mattroseb8wk2;
  2. import java.util.Scanner;
  3.  
  4. public class Day07H {
  5.     public static void main(String[] args) {
  6.         Scanner sc = new Scanner(System.in);
  7.         String name = "";
  8.         String address = "";
  9.         byte age = 0;
  10.         System.out.print("Enter Name : ");
  11.         name = sc.nextLine();
  12.         System.out.print("Enter Age : ");
  13.         age = sc.nextByte();
  14.         sc.nextLine();
  15.         System.out.print("Enter Address : ");
  16.         address = sc.nextLine();
  17.        
  18.         System.out.print(name + " is " + age + " years old ");
  19.         System.out.print("and is now living at " + address);
  20.        
  21.     }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment