-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathdecisions.java
More file actions
44 lines (42 loc) · 1.46 KB
/
Copy pathdecisions.java
File metadata and controls
44 lines (42 loc) · 1.46 KB
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
42
43
44
class decisions
{
public static void main(String []args)
{
int age = 21;
if(age >= 18){
System.out.println("You're good to vote");
}else{
System.out.println("Nahh, grow up");
}
// Set the value of the day variable to 3
int day = 3;
// Use a switch statement to determine the name of
// the day of the week
switch (day) {
case 1:
System.out.println("Monday");
break; // If day equals 1, print "Monday"
case 2:
System.out.println("Tuesday");
break; // If day equals 2, print "Tuesday"
case 3:
System.out.println("Wednesday");
break; // If day equals 3, print "Wednesday"
case 4:
System.out.println("Thursday");
break; // If day equals 4, print "Thursday"
case 5:
System.out.println("Friday");
break; // If day equals 5, print "Friday"
case 6:
System.out.println("Saturday");
break; // If day equals 6, print "Saturday"
case 7:
System.out.println("Sunday");
break; // If day equals 7, print "Sunday"
default:
System.out.println("Invalid day");
break; // If day is not in the range 1-7, print "Invalid day"
}
}
}