COMP 110-001 - Introduction to Programming (Spring 2009)

Lab 1

25 points

Assigned: January 23rd

Due: January 29th by midnight

Description

Part 1

On the course webpage you will find VendingMachineChange.java, which we wrote in class. Copy and paste the program into a new Java file in jGrasp. Compile (green plus sign) and run (red running man) VendingMachineChange.java. Don't forget to change the header at the top of the program to say your name and due date.

Recall the following pseudocode we developed in class.

Read through the pseudocode as well as VendingMachineChange.java and make sure you understand the algorithm. Place each line of pseudocode into VendingMachineChange.java as comments directly above the line or lines that complete the action. The first line of pseudocode is already in the code as a comment. You may abbreviate the pseudocode comments when you place them into the code.

Part 2

On the course webpage you will find TotalCost.java. You need to complete this program so that it calculates the total cost of a new coat including tax. (The user will input the cost of the coat and the tax rate.) The user will input the tax rate without using the % percent symbol. For example, if the user inputs 5.5 for the tax rate, your program should compute the total cost using a tax rate of 5.5%.

Write pseudocode for how you would solve this problem. Following your pseudocode, complete the program TotalCost.java. Just like in Part 1, insert your pseudocode as comments into your program.
NOTE: you are dealing with money so you should declare your variables as double, a number with decimal points, instead of int, whole numbers. Also, when reading doubles from the keyboard you would write keyboard.nextDouble() instead of keyboard.nextInt().

Remember to edit the Program Header at the beginning of the program to reflect your name as well as a description of the program.

Submission

For this assignment you will need to create a Jar file that contains the source code for VendingMachineChange.java AND TotalCost.java that you edited as part of this assignment. Follow these instructions for creating a Jar file.
The Jar file you submit must be named yourlastname_lab1.jar, where yourlastname is your last name

Submit yourlastname_lab1.jar via the UNC Blackboard System before the deadline.

Grading