- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab01.java
More file actions
Latest commit
54 lines (50 loc) · 1.01 KB
/
Copy pathLab01.java
File metadata and controls
54 lines (50 loc) · 1.01 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
45
46
47
48
49
50
51
52
53
54
packageanimals;
publicclassLab01
{
publicstaticvoidmain(String[] args)
{
Consolecon = newConsole();
while(true)
{
charreturned = con.nextCmd();
if(returned == 'e')
{
System.exit(1);
} else {
map(returned);
}
}
// TODO
// Here you must add code to do the following:
// 1) Read a command from the console.
// 2) If the command is 'e', print "Exit" and
// exit the program using System.exit().
// 3) Otherwise, print the corresponding message
// for each command:
// 'a' -> "Alligator"
// 'b' -> "Bear"
// 'c' -> "Cat"
// 'd' -> "Dog"
// 4) Loop until the console returns an 'e'.
}
publicstaticvoidmap(charletter)
{
switch(letter)
{
case'a':
System.out.println("Alligator");
break;
case'b':
System.out.println("Bear");
break;
case'c':
System.out.println("Cat");
break;
case'd':
System.out.println("Dog");
break;
default:
System.out.println("Enter a letter please...");
}
}
}