Objectives
- Get user input from the command line
- Perform simple calculations
- Display output (literal text and variable values) to the screen
The source code listings for these programs, and all others due in this course, must include comments at the beginning of the source code which contain your name, the course, the date, and the assignment number. Follow style conventions covered in class. Assignments should be submitted to the assignment dropbox in Desire2Learn. You must submit the source code (.java) files rather than the object (.class) files.
In the early days of personal computers text games were a big hit. The following sample output is very similar to the display from one of those early games. Write a program which will display the sample output exactly as it is shown in the sample run for program #1.
A text version of the output suitable for copying and pasting is available as trek.txt
Combat area Condition: Red ------------------------------ * * Stardate 3004 * Condition *RED* * * Quadrant 2 , 6 <E> * Sector 8 , 3 +K+ Photon torpedoes 7 * Total energy 2785 * Shields 1800 * Klingons remaining 5 * * >B< * ------------------------------ Command?
Write a program which calculates the number of canisters of Pringles a user must purchase to satisfy their potato crisp cravings. Assume there are 100 crisps per full-size canister. You should round the number of canisters to be purchased to the nearest integer. See the sample run for program #2 for an example.
How many crisps do you eat per day (on average): 20 How many days worth of crisps do you want available: 365 Crisps/day: 20 Inventory in days: 365 You should buy 73 full-size canisters of crisps.
How many crisps do you eat per day (on average): 18 How many days worth of crisps do you want available: 365 Crisps/day: 18 Inventory in days: 365 You should buy 66 full-size canisters of crisps.