COMP 110-003

Program 1: Coffee In Time

50 points

Assigned: Tuesday, Jan 22
Due: Thursday, Jan 31

Description

In the world of movie In Time, time has become the ultimate currency. The money you have is the time displayed on your arm, and you pay everything in days, hours, and minutes. (We don't have to use seconds in this assignment.)

Now assume that you are running a coffee shop in that world. The price for coffee is: 3 minutes for a COFFEE, 5 minutes for a COFFEE PLUS and 7 minutes for a COFFEE X. If you know how many cups of coffee you can sell every day, how much time can you earn every day?

Write a program that asks how much cups of coffee you can sell everyday and then outputs the total number of days, hours, and minutes you can earn. Note: there are 1440 minutes in a day.

Compute the total number of minutes you can earn and then convert that to days, hours and minutes, in that order.

For example, if you can earn 1503 minutes everyday, the output should read:
1 days, 1 hours, and 0 minutes
It should not be output as:
0 days, 25 hours, and 3 minutes

Here's an example run (the user input is in italics):

Hello! How many COFFEE can you sell every day?
1000

How many COFFEE PLUS can you sell every day?
500

How many COFFEE X can you sell every day?
100

You can earn 6200 minutes.
That is 4 days, 7 hours, and 20 minutes.

Hint

Pay special attention to the paragraph about division on p. 69-70 (p. 63 for 5th Ed) of the textbook.

Extra Credit

Change your output to be grammatically correct for all outputs. That is, 1 hour should be singular and 2 hours should be plural. The same is true for days and minutes.

If you can earn 1503 minutes, the output should read:

1 day, 1 hour, and 3 minutes

If you can earn 1561 minutes, the output should read:

1 day, 2 hours, and 1 minute
Note that for the extra credit part, you will need to refer to first 3 pages of Section 3.1 in textbook.

What to Do

• Create a Java Project named Time with a Class named Time.java
• Make sure you put the standard program header at the top of your code.
• Write all code in Time.java
• Follow the instructions for creating a JAR file containing your Java source code. The Main Class in your JAR file should be "Time".

What to Turn in

Submit via Sakai the following:

• Your `yourlastname_program1.jar` file (where `yourlastname` is your last name), which includes your `Time.java` source file
• In the program header comment section add a short write-up of questions you had and/or problems you encountered while doing this assignment

Requirements

When I examine your program, it must satisfy the following requirements. The maximum point value for each is shown in brackets.

1. [2] You put the standard program header at the top of your code file.
2. [3] Your class, Java source file, and JAR file must be appropriately named (as specified above).
3. [2] Your JAR file was created correctly (contains both .java and .class files and MANIFEST file)
4. [10] You must prompt the user for the number of COFFEE, COFFEE PLUS and COFFEE X that are sold every day.
5. [15] You must output the correct total number of minutes you can earn.
6. [15] You must output the correct total time in days, hours, and minutes.

/* This is a
multi-line comment */

// this is a single line comment

where appropriate. In addition, your code must be neatly and clearly formatted using appropriate "white space."
8. [5] Extra Credit
Notes:
• If your program doesn't compile or run (i.e., has a syntax error), you may receive partial credit for the items listed above in bold.