-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathdrinkValidity.java
More file actions
43 lines (26 loc) · 807 Bytes
/
drinkValidity.java
File metadata and controls
43 lines (26 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.mycompany.problemssolving;
import java.util.Scanner;
public class drinkValidity {
public static void main(String[] args)
{
int age = 0;
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter age between 18 and 21)");
age = keyboard.nextInt();
switch(age)
{
case 21:
System.out.println("You can drink AND vote legally!");
break;
case 20:
case 19:
case 18:
System.out.println("You can vote legally!");
break;
default:
System.out.println("You cannot drink!");
break;
}
System.out.println("program end!");
}
}