-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab_1.2.java
More file actions
58 lines (52 loc) · 1.13 KB
/
Copy pathLab_1.2.java
File metadata and controls
58 lines (52 loc) · 1.13 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
55
56
57
58
import java.io.*;
public class Lab01
{
public static void main (String[]args) throws Exception
{
String temp = "";
char val;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while(true)
{
temp = br.readLine();
if(temp.length() > 1)
val = 'q';
else
val = temp.charAt(0);
switch(val)
{
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;
case 'e':
System.out.println("Exiting...");
System.exit(1);
default:
System.out.println("Please enter a letter a-e...");
break;
}
}
//lol
// 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'.
}
}