S4_changecomputation_medium - agarmstrong21/agarmstrong_swd_2019 GitHub Wiki

S4_ChangeComputation_Medium

Portfolio Home Page

Problem Statement

To make things easier for cashiers and also to minimize errors, most modern cash registers automatically calculate the change to be given. In this problem, you will be creating a program to support this feature.

Easy

In this problem, you must create a program that allows the user to enter in price of an item and the amount the customer paid, and then displays the amount of change to be given. The program must also display how many of each unit of currency must be given in change. The cash register contains the following currency units:

  • 20 Dollar bills
  • 10 Dollar bills
  • 5 Dollar bills
  • 1 Dollar bills
  • Quarters
  • Dimes
  • Nickels
  • Pennies

You can assume that the cash register has an infinite amount of each currency unit in it. Do not assume the customer is paying in the most efficient manner. The program needs to know how many of each bill and coin the customer paid the total amount with.

NOTE: Most people will do this with double precision, but 4.59 is not re-presentable in double (only 4.58999999999999999), so there are problems where the naïve solution of using double will result in an off by one error.

Medium

Initialize the number of available currency units to be random numbers between 0-15. In this case, you may not always be able to give change in the most efficient manner. If your program is unable to give the correct amount of change, your program must display an appropriate error message. Your program must allow the cashier to input many transactions, thus increasing and decreasing the number of each currency unit that exists in the cash register. Your program must display the current amounts of each currency unit before each transaction so that the user knows how many of each is in the cash register.

User Documentation

ChangeComputation is a program that creates a randomly generated drawer and starts a cash transaction. The user is asked for the price of the item. Then asks how the user will pay for it in bills. (asking for 20's, 10's, 5's, 1's, and cents) Once inputted, the program will check the the amount to make sure it is correct, add it to the drawer, and give change back if necessary. The drawer is stored for the next transaction. The user will be asked if it would like to continue, if not, the program will end.

Developer Documentation

ChangeComputationDriver will call ChangeComputationTest which starts the front end of the program. The drawer will be randomly generated and continue into a while loop that will continue until the user inputs anything but numbers and "y"s. y stands for yes to continue transactions. The Drawer will print out using the unique print method. Then asks the user to input a total amount of the item. Once that is done, the user must input the given money in bill and cent format. Then the program will call difference to find the difference between the total and given. Then will call getMoney which will print out the change of that is to be given. This will all be printed out at the end before it asks to see if another transaction needs to be started. The drawer will have money added it to when the money is given and will take money out of the drawer when change is given.

None at this given moment. Will keep updated.

Java Docs

The java documents are served from a local web server on this machine. To start the web server, navigate to the directory immediately above where the source code is checked out (i.e. ~/git ) and then use "python -m SimpleHTTPServer" in that directory.

cd ~/git
python -m SimpleHTTPServer&
```
Note: if you are running python 3 (which you can check via opening a terminal and typing: python --version), then the command is:


```shell
python3 -m http.server
```

[JavaDocs for S4_ChangeComputation_Medium](http://localhost:8000/agarmstrong_swd/oral_exam1/S4_ChangeComputation_Medium/doc/allclasses.html)

## Source Code
[Source Code for S4_ChangeComputation_Medium](https://class-git.engineering.uiowa.edu/swd2019/agarmstrong_swd/tree/master/oral_exam1/S4_ChangeComputation_Medium)
⚠️ **GitHub.com Fallback** ⚠️