Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /* ==========================================================
- Chapter 2: Syntax section A- conditional clause
- Ex2: Under age, Adult or pensioner
- ==========================================================
- */
- public class MyProgram {
- public static void main(String[] args) {
- float age;
- Scanner s=new Scanner(System.in);
- //user input
- System.out.println("Enter your age: ");
- age=s.nextFloat();
- //display message
- if(age<18)
- System.out.println("you are Under age!");
- else if(age<65)
- System.out.println("you are an Adult!");
- else
- System.out.println("you are a pensioner!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment