-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNibbleMonsterWithLoopCounter.java
More file actions
30 lines (24 loc) · 1.15 KB
/
NibbleMonsterWithLoopCounter.java
File metadata and controls
30 lines (24 loc) · 1.15 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
import java.util.Scanner;
public class NibbleMonsterWithLoopCounter {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("How many snacks do you have for the monster? Enter a number: ");
int numSnacks = scanner.nextInt();
int snacksRemaining = numSnacks;
while (snacksRemaining > 0) {
System.out.print("Enter a nibble: ");
char input = scanner.next().charAt(0);
if ((input >= '0' && input <= '9')) {
System.out.println("Happy Message Type 1: The monster is delighted with this snack!");
} else if (input >= 'A' && input <= 'F') {
System.out.println("Happy Message Type 2: The monster is bouncing with joy from this snack!");
} else if (input >= 'a' && input <= 'f') {
System.out.println("Happy Message Type 3: The monster is on top of the world with this snack!");
} else {
System.out.println("Unhappy Message: Invalid input. This is not a nibble.");
}
snacksRemaining--;
}
scanner.close();
}
}