hpilo

chapter2_SyntaxA_Ex2

Dec 15th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /*  ==========================================================
  4.              Chapter 2: Syntax section A- conditional clause
  5.  
  6.                    Ex2: Under age, Adult or pensioner
  7.     ==========================================================
  8. */
  9. public class MyProgram {
  10.     public static void main(String[] args) {
  11.  
  12.         float age;
  13.         Scanner s=new Scanner(System.in);
  14.  
  15.         //user input
  16.         System.out.println("Enter your age: ");
  17.         age=s.nextFloat();
  18.  
  19.         //display message
  20.         if(age<18)
  21.             System.out.println("you are Under age!");
  22.         else if(age<65)
  23.             System.out.println("you are an Adult!");
  24.         else
  25.             System.out.println("you are a pensioner!");
  26.  
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment