CS
010 - Introduction to Computer Science I
Assignment 1:
DUE: Fri, January 14 before 7:00pm
Collaboration is strongly ENCOURAGED. You can work in teams, but programs must represent YOUR OWN original work. Teams can work on the algorithm together and help debug/test each others code. However, copying code from ANY source (any book, current or past students, past solutions, the web, etc.) is STRICTLY FORBIDDEN.
Code that is turned in, must be contained in a .cpp file named main.cpp. Files of ANY other format will not be graded (e.g. main.doc, main.txt, etc…).
You must turn your work in using electronic turnin as in lab1, from a lab computer on campus, TURNING IN FROM HOME WILL NOT WORK!
Turn in online to as1 folder. If you turn your assignment in to the wrong folder, your assignment may not be graded. If it is graded, you will lose 2 pts (out of 10).
Remember to include the following header information at the top
of your program;
// Course: CS 10
//
// Lecture Section: ... 001 or 002
// Lab Section: ... 021, 022, etc)
//
// Assignment #: ... assignment 2, 3, etc.
//
// Last Name: Enter your LAST (family) name here (eg, Doe)
// First Name: Enter your FIRST (given) name here (eg, John)
//
// ID Number: Enter your ID number here (eg, 860-00-0000)
// lab login id: Enter your cs10 login here (eg, jdoe)
//
// Email address: Enter your UCR email address here (eg,
jdoe@cs.ucr.edu)
//
// Teammates: List the names of the teammates you worked with
//
//
=======================================================================
For this assignment
you will write a program that directs a cashier on how to give change.
The program takes two inputs: the amount due, and the amount received
from the customer. Compute the difference (amount of change to hand
back), and compute the dollars, quarters, dimes, nickels, and pennies
that the customer should receive in return.
To simplify your code, you may read in the amount due, and the amount
received as pennies (integers). For example: one dollar would be input
as 100, a dollar forty five as 145, etc...
Hint: The number of
dollars you need to hand back is equal to the change amount divided by
100. Then, you need to update the amount of change by subtracting
off the number of dollars you handed back (in terms of hundreds of
pennies).
For example:
dollars = change / DOLLAR_VALUE
change = change - (dollars * DOLLAR_VALUE)
Something similiar
would be done for quarters, dimes, etc...
Example program run 1:
Enter amount due: 1
Enter amount received: 100
Total Change is 99 cents
0 dollar(s)
3 quarter(s)
2 dime(s)
0 nickel(s)
4 pennie(s)
Example program run 2:
Enter amount due: 234
Enter amount received: 500
Total Change is 266 cents
2 dollar(s)
2 quarter(s)
1 dime(s)
1 nickel(s)
1 pennie(s)