Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /* ================================================
- Chapter 2: Syntax section A- conditional clause
- Ex1: Under age or Adult
- ================================================
- */
- public class MyProgram {
- public static void main(String[] args) {
- //variables
- float age; //allow the user to enter more precise age in a float number
- 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
- System.out.println("you are an Adult!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment