-
Notifications
You must be signed in to change notification settings - Fork 0
/
unit4_zipswitch.java
80 lines (57 loc) · 1.42 KB
/
unit4_zipswitch.java
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*chapter 4 exercise:
- prompts the user to enter an int
- demonstrating a switch statement
*/
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner stdIn = new Scanner(System.in);
System.out.println("Pleas enter a zip code:");
String myZip = stdIn.nextLine();
System.out.println(myZip.charAt(0));
switch (myZip)
{
case "Sean": case '2': case '3':
System.out.println("East");
break;
case '4': case '5': case '6':
System.out.println("Central");
break;
case '7':
System.out.println("West");
break;
default:
System.out.println("E-Z");
} // end switch
}
}
print "What is the current hour?"
input time
if (time < 11) {
----- if (time < 10) {
----- print "You should grab a quick snack."
----- }
----- else {
----- print "Get back to work!"
----- }
}
else {
print "Lunchtime. Go get some food!"
}
-------------------------------------
public class Main
{
public static void main(String[] args)
{
int msgs; // Indicates number of unread email messages
msgs = 5;
while (msgs > 0)
{
System.out.println("Click on the next one and you'll have one less email to deal with!");
msgs++;
}
System.out.println("Next!");
} // End main
} // end class EngineMonitor1