CIS 160 - Basic I/O assignment

Objectives

  • Get user input from the command line
  • Perform simple calculations
  • Display output (literal text and variable values) to the screen

Overview

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.

Program #1

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

Sample run for program #1

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?

Program #2

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.

Sample runs for program #2

Sample run #1

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.

Sample run #2

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.

Rubric

  • Program #1
    • 10 points for correct operation (the output must match exactly)
    • 5 points for proper documentation comments and correctly following coding conventions (indentation, naming rules, etc.)
  • Program #2:
    • 5 points for having a working program (and results must be based upon user input)
    • 5 points for reasonable code for user input (including descriptive prompts)
    • 5 points for reasonable code for the calculations
    • 5 points for reasonable code for the output (your output should match the sample exactly)
    • 5 points for proper documentation comments and for correctly following coding conventions (indentation, naming rules, etc.)