Advertisement
Guest User

HomeWork 1

a guest
Jul 22nd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FirstAssignment {
  4.     public static void main(String[] args) {
  5.  
  6.         final int currentYear = 2019; //setting current year
  7.         Scanner s = new Scanner(System.in); //creating a scanner
  8.  
  9.  
  10.         System.out.println("Please enter your year of birth:");
  11.         int yearOfBirth = s.nextInt(); //getting year of birth
  12.  
  13.         int userAge = currentYear - yearOfBirth; //calculating user age
  14.  
  15.         System.out.println("Please enter your ID number:");
  16.         long idNum = s.nextLong(); //get id number
  17.  
  18.         System.out.println("Please enter your Height:");
  19.         float userHeight = s.nextFloat(); //get user height
  20.  
  21.         //  System.out.println("What is your gender M/F:");    // NOT IN USE IN THIS VERSION
  22.         //  char gender = s.next().charAt(0); //get user gender    // NOT IN USE IN THIS VERSION
  23.  
  24.         System.out.println("What is your gender? Enter TRUE for male, FALSE for female:");
  25.         boolean isMale = s.nextBoolean();
  26.  
  27.         //Display the information
  28.         System.out.println("---------------------------");
  29.         System.out.println("Your are " + userAge + " years young.");
  30.         System.out.println("Your id number is: " + idNum);
  31.         System.out.println("Your height is: " + userHeight);
  32.         //  System.out.println("Your are a: " + gender);   // NOT IN USE IN THIS VERSION
  33.  
  34.         //checking is user is male or female
  35.         if (isMale == true) {
  36.             System.out.println("Your are a Male");
  37.         } else {
  38.             System.out.println("Your are a Female. How u doing?!");
  39.         }
  40.  
  41.  
  42.     }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement