CSCE 2004 - Programming Assignment 1
Electronic Submission Due: Wednesday 11:59 pm Feb 8, 2012
Hardcopy Due: Turn in at beginning of next class or lab, or in JBHT 504 by noon Friday. 10, 2012

 

1. Problem Statement:

The goal of this programming assignment is to develop a program for renting a movie from a movies vending machine.

At the beginning, the program should print out your Name and UARK ID number. The program should show the menu of available movies in the machine as well as their rent prices per night. Then, a user should be prompted to enter the number of the movie s/he wants to rent (one only). In addition, the user should be prompted to enter the number of nights s/he wants to rent the movie for.  Next, the program should ask the user to deposit a sufficient amount of money to rent the movie. If the cash deposited is insufficient, the user gets another chance to deposit more money to be sufficient; otherwise, the transaction is terminated. The message should be in the form “Insufficient amount of money, you still need to deposit () dollars and () cents or more to rent the movie”. If the amount of money is sufficient or if the user deposits more money such that the cash becomes sufficient, the program should compute the change and print out the bill in the form:

You have rented the movie number #() for () nights

Your bill is () dollars

Your change is () dollars

Thanks for using our store! Good Bye.

The program should also do some basic error checking to make sure the user enters appropriate values when prompted. For example, if the user enters a negative or invalid number, an error message should be displayed and the program should end.

2. Design:

Looking at the requirements above, try to sketch out the "flow" of the program using either a diagram or a sequence of conditional statements written in pseudo-code. Mentally walk through each of the possible paths, and think about what conditions and calculations need to be performed. Once you have done this, work out the basic formulas you will use to count change, with a calculator, or with a spreadsheet to verify they are correct. The following algorithm description is designed to help you along in this process.

An algorithm is a step-by-step procedure, composed of a finite list of well-defined instructions, used to accomplish some task.

  1. Display the menu of items on the screen

Here are the available movies and their rent prices per night

    1. Lord of the Rings    Price: $1.5               

    2. Brave Heart           Price: $1.25              

    3. Titanic                   Price: $0.75              

    4. Tangled                 Price: $1.30              

    5. Avatar                  Price: $1.60    

  1. Tell the user to select one item from the items displayed
  2. If the selection is incorrect 
        Display an error message on the screen, and terminate the transaction
  3. Else (if the selection is correct) 
       Ask the user to enter the number of nights s/he wants to rent the movie for

               Ask the user to enter sufficient money

5.          If the money deposited is insufficient

6.               Compute the needed money and prompt the user to deposit it

7.               If the user does not deposit enough money again, prompt him/her and terminate the   

             transaction.

8.         Else (If the money is/becomes sufficient) 

9.              Calculate the cost and the change and display them on the screen

Sample output

+----------- Welcome to Movies Store ------------------+

| Here is the available movies and their rent prices  |

| 1. Lord of the Rings    Price: $1.5                            |

| 2. Brave Heart           Price: $1.25                           |

| 3. Titanic                   Price: $0.75                            |

| 4. Tangled                 Price: $1.30                            |

| 5. Avatar                   Price: $1.60                            |

+-------------------------------------------------------------+

 

Please Enter the Number of Movie you Would Like to Rent

3

For How Long you Want to Rent the Movie (In Nights)

3

Enter Sufficient Cash

2

Insufficient Amount of Money, Please enter another 0 Dollars and 25 Cents

1

You have Rented Movie #3 For 3 Nights

Your Bill is: $2.25

Your Change is: $0.75

          Thanks for using our store! Good Bye.

3. Implementation:

Start your program with comments based on your design and add portions of code a little at a time. Compile and run your program on a regular basis, so you always have something that runs, even if it only does part of the job. Make sure you have completed the first task, e.g., printing your name to the screen, before you start writing code for the second task.

4. Testing

Test your program to check that it operates correctly for all of the requirements listed above. Also check for the error handling capabilities of the code. Save your testing output in text files for submission on the program due date.

To create a test file from your code, you can simply copy and paste the contents in the output window and paste it into a text editor.

5. Documentation:

When you have completed your C++ program, write a short report (less than one page long) describing what the objectives were, what you did, and the status of the program. Does it work properly for all test cases? Are there any known problems? Add this report to the testing file to be submitted electronically.

6. Submission

Click on the “Upload Files” button. Next, create a new folder and name it as “HW1”. Then, click on the folder and upload two files; one for the code (Code.cpp or Code.txt) and the other for testing and documentation (Report.txt). Make sure to upload the code in one of the two formats .txt or .cpp format. When you finish uploading, confirm your uploading by clicking on “Send for Marking” button.

The dates on your electronic submission will be used to verify that you met the due date above.  More than 3 days late will not be accepted. So hand in your best effort on the due date.

You should also PRINT a copy of these files and hand them in during the first class that follows the assignment deadline. Include the Homework Grading Cover Sheet that is linked from the Projects page. Points will be deducted if the cover page is missing.

7. Late Submission Penalties

§  Electronic copy submitted late: 1st day: -10 points, 2nd day: -20 points. 3rd day: -30 points, After: -100 points

§  No hardcopy submitted: -20 points

§  Hardcopy submitted late: -10 points
Incorrect format (electronic copy): 1 reminder and -5 points, After: -100 points