Purposes of this project:
get you started using basic Java constructs, including:
The use of Scanner to get user input
Declarations, assignment statements, if and while statements.
System.out.print and println methods.
General idea:
Simulate the operation of a Coke machine. This machine offers Coke, Coke Zero, and Caffeine-free Diet Coke. All drinks cost $1 (100 cents). The machine does not take dollar bills or pennies, but it does take nickels, dimes, and quarters. When enough money has been entered, a drink may be selected, and any change is returned (the specific coins are listed).Only coins in denominations of 5, 10, and 25 cents are accepted. Any other denomination (33 cents, 50 cents, etc.) is rejected and returned. More than one drink may be purchased (that is, the program doesn't quit after selling one drink).There is no way to turn off the coke machine. When you run the program from within Eclipse, you can stop it by pressing the red square.
Example:
Here is an example of the use of the program. Program output is blue, user input is brown.
Insert coin: 25
Amount entered: 25
Insert coin: 25
Amount entered: 50
Insert coin: 10
Amount entered: 60
Insert coin: 15
Rejecting 15 cent coin
Amount entered: 60
Insert coin: 25
Amount entered: 85
Insert coin: 10
Amount entered: 95
Insert coin: 25
Amount entered: 120
Please make selection:
1 - Coke
2 - Coke Zero
3 - Caffeine Free Diet Coke
Your choice: 2
Dispensing Coke Zero
Returning dime
Returning dime
get you started using basic Java constructs, including:
The use of Scanner to get user input
Declarations, assignment statements, if and while statements.
System.out.print and println methods.
General idea:
Simulate the operation of a Coke machine. This machine offers Coke, Coke Zero, and Caffeine-free Diet Coke. All drinks cost $1 (100 cents). The machine does not take dollar bills or pennies, but it does take nickels, dimes, and quarters. When enough money has been entered, a drink may be selected, and any change is returned (the specific coins are listed).Only coins in denominations of 5, 10, and 25 cents are accepted. Any other denomination (33 cents, 50 cents, etc.) is rejected and returned. More than one drink may be purchased (that is, the program doesn't quit after selling one drink).There is no way to turn off the coke machine. When you run the program from within Eclipse, you can stop it by pressing the red square.
Example:
Here is an example of the use of the program. Program output is blue, user input is brown.
Insert coin: 25
Amount entered: 25
Insert coin: 25
Amount entered: 50
Insert coin: 10
Amount entered: 60
Insert coin: 15
Rejecting 15 cent coin
Amount entered: 60
Insert coin: 25
Amount entered: 85
Insert coin: 10
Amount entered: 95
Insert coin: 25
Amount entered: 120
Please make selection:
1 - Coke
2 - Coke Zero
3 - Caffeine Free Diet Coke
Your choice: 2
Dispensing Coke Zero
Returning dime
Returning dime
Comments
Post a Comment