-
Notifications
You must be signed in to change notification settings - Fork 0
/
TrickOrTreat.java
35 lines (32 loc) · 1.12 KB
/
TrickOrTreat.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
//Name: Prabhav
//Period: 1A
import java.util.*;
public class TrickOrTreat
{
public static void main(String[] args)
{
Scanner console = new Scanner(System.in);
System.out.println("How much candy are we giving out today? ");
int numCandy = console.nextInt();
System.out.println("What kind of candy is it? ");
console.nextLine();
String candyName = console.nextLine();
System.out.println();
while (numCandy >= 100)
{
System.out.println("Hello! Here are 2 "+candyName+".");
System.out.println("We have "+numCandy+" "+candyName+" left.");
System.out.println();
numCandy -= 2;
}
while (numCandy > 1)
{
System.out.println("Hi! Here is a "+candyName+".");
System.out.println("We have "+numCandy+" "+candyName+" left.");
System.out.println();
numCandy -= 1;
}
System.out.println("Hi! Here is the last "+candyName+".");
System.out.println("Sorry! You can go home now!");
}
}