Home >  T.A >  cs10 ( Spring 2002 ) >  Lab 3

  CS10 Sec#24, #29, #30 : Topics covered in Lab #3
T.A: Demetris Zeinalipour
(Spring 2002)
Print this Page   
Top


Academic Dishonesty Policy
If you haven't signed the Academic Dishonesty sheet the previous week please ask me to sign it.
Top


Working with Arithmetic Operators
Write a program that determines the coins to give back to a customer for change. Let the user enter the amount of the change in cents (integer). Calculate and print out how many quarters, dimes, nickels, and pennies, should be given back to fulfill this amount of change. Give as many higher value coins as possible. Solution is here (After coming friday)

For example, if the amount of change was 58 cents, then your program should calculate to give back

2 quarters

0 dimes

1 nickel

3 pennies



* Be sure to put all your information (login, lab section, …) at the top of your program. I will be checking off your program during lab to give you points or any help you may need.
* * Also please keep in mind the "Style Considerations" section of Lab 2, because you have to apply again all rules that we have mentioned
Top


C++ Built-In Data Types

Check out the following table of C++ Built-In data types. This wil help you to understand when you should use a particular datatype. Using the correct data type makes our program "faster" and better. In that way we are showing respect to the machine resources. I don't ask you use the following table but if you feel that you want to improve your C++ knowledge you can always use it as a reference.

e.g If I ask you to define a variable for your age you could of course use 'int'. Using 'int' though has an overhead since it range from -2^31 until 2^31 which means that the age variable can have a value between -2,147,483,648 and 2,147,483,647.

Don't you think that this is a too big range for the age field?.

On the other hand is it ever possible that the age field has a negative value?.

Of course not. So you could use 'short age' which would allocate only -32768 until 32767 or you could even better use 'unsigned short age' which would be only 0 until 65535 and which is more than enough to store the age value.


Top