Advertisement
chaibs

targil1-vars

Dec 12th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. package myfirst;
  2. import java.util.Scanner;
  3.  
  4. public class hello {
  5.  
  6.     public static void main(String[] args) {
  7.         final int current_year = 2017;
  8.         int year = 0, age = 0;
  9.         long id = 0;
  10.         double height = 0;
  11.         char gender;
  12.        
  13.         Scanner s = new Scanner(System.in);
  14.        
  15.         System.out.println("Please enter the year you were born:");
  16.         year = s.nextInt();//get user year of birth
  17.        
  18.         System.out.println("Please enter your ID:");
  19.         id = s.nextLong();//get user id
  20.        
  21.         System.out.println("Please enter your height:");
  22.         height = s.nextDouble();//get user height
  23.        
  24.         System.out.println("Are you Male or Female?(M/F):");
  25.         gender = s.next().charAt(0);//get user gender
  26.        
  27.         age = current_year - year;//calculating users age
  28.         System.out.println("Your age is: " + age);//result
  29.        
  30.         System.out.println("Your ID is: " + id);//result
  31.        
  32.         System.out.println("Your height is: " + height);//result
  33.        
  34.         System.out.println("You are a: " + gender);//result
  35.     }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement