Skip to main content
ICT
Lesson A3 - Primitive Data Types
 
Main Previous
Title Page >  
Summary >  
Lesson A1 >  
Lesson A2 >  
Lesson A3 >  
Lesson A4 >  
Lesson A5 >  
Lesson A6 >  
Lesson A7 >  
Lesson A8 >  
Lesson A9 >  
Lesson A10 >  
Lesson A11 >  
Lesson A12 >  
Lesson A13 >  
Lesson A14 >  
Lesson A15 >  
Lesson A16 >  
Lesson A17 >  
Lesson A18 >  
Lesson A19 >  
Lesson A20 >  
Lesson A21 >  
Lesson A22 >  
Lesson AB23 >  
Lesson AB24 >  
Lesson AB25 >  
Lesson AB26 >  
Lesson AB27 >  
Lesson AB28 >  
Lesson AB29 >  
Lesson AB30 >  
Lesson AB31 >  
Lesson AB32 >  
Lesson AB33 >  
Vocabulary >  
 

LAB ASSIGNMENT A3.2 page 14 of 14

Coins

Background:

Some cash register systems use change machines that automatically dispense coins. This lab will investigate the problem solving and programming behind such machinery. You always want to use the fewest coins possible. You should use integer mathematics to solve this problem.

Provide the number of cents through the constructor. Write a method that calculates the number of each type of coin.

Examples:
     
 35 cents =>
 Quarter(s)   1
 Dime(s)      1
 Nickel(s)    0
 Penny(s)     0
 
 41 cents =>
 Quarter(s)   1
 Dime(s)      1
 Nickel(s)    1
 Penny(s)     1

Assignment:

  1. Follow the same format that was used in Lab Assignment A3.1 (Easter), using a driver and a class called Coins.

  2. Run the samples from above to check your work.

  3. Run the following three samples and copy the sample runs into your class file, print out the code for the class and hand in.

    94 cents
    59 cents
    19 cents

  4. Do not worry about singular versus plural endings, i.e. quarter/quarters.

 

Main Previous
Contact
 © ICT 2006, All Rights Reserved.