CSCE 145, Lab 02

Objective:

Perform a small calculation with user input.

 

You are writing a little point of sale program for a kiosk, called “Bear Necessities”. The store only sells Salmon, Combs, and Napkins. The currency will be Berries. The user will enter the number of each item and you will return the total cost in Berries. Use the following table for cost in berries:

Item

Berries

Salmon

50

Comb

100

Napkins

20

Steps:

1.       You will need to create the project in Dr. Java.

a.       Make sure the public class name matches the filename. The filename should match the purpose of the program.

b.      Make sure it has a main() method (just like the previous lab or in the Java code example below).

c.       The output should be similar to the following output from Dr. Java:

2.       Since we may have not quite gotten to more complicated equations yet, here is some code. Please read the comments (between /* and */ , in green).

a.       Note in particular that, ‘*’ means multiply (there’s no multiply symbol on the keyboard) – you will need it for this lab.

b.      Java typically obeys the order of operations you would expect, e.g. 2+3*4 is 14 in Java (multiplication happens before addition unless parentheses change it).

c.       When the code is run and the number “4” is entered, here is the output:

3.       When you believe you are done, show your Lab TA. Make sure you have signed the roll. Do not forget to upload the code to dropbox.cse.sc.edu before you leave.

 

Lab Report Questions:

1.       What issues do you imagine would occur if your program had to support a real store, such as a grocery store? Give two obvious issues and brainstorm some sort of solution for each, though the solution may be similar (even though it will likely be well past your current coding skills).

2.       If you were working with real currency, e.g. dollars, what would you expect to have to change, besides calling the currency “dollars” or “$”? Give at least one change.

Finally:

Upload your final .java file to dropbox.