#### Lab 1120 - Centalyzer

##### Description

You have just accepted a job from a coin dealer who needs your help. One of her best customers buy bags of 1000 cents from her hoping to find a rare coin in the mix.

She has many sealed bags each containing 1000 cents that you can weigh accurately but not open because the customer would think the more valuable coins had already been taken out. The customer doesn't want to buy any bags that are mostly new coins because there's little chance of finding a rare coin in a bag of recently-minted cents.

The coin dealer can charge more for bags that have a higher percentage of coins dated 1982 or earlier in the bag. Why 1982? Up to 1982, pennies were 95% Copper and 5% tin and zinc. After 1982 the composition became 97.6% zinc and 2.4% copper. The weight of each: 3.1 grams (1982 or earlier) and 2.5 grams (after 1982).

Use this fact to determine how many 1982 or earlier coins and post-1982 coins are in a sealed bag of 1000 coins. You can weigh the bag with the coins inside accurately, and you know the bag alone weighs exactly 7.0 grams.

##### Test Data

Some coin bags will measure exactly the weight expected. For example, if there are 115 1982-or-earlier coins in the bag, the weight will be 2576 grams. Some coin bags will have coins that are quite worn, and in this case the actual weight might be 2575.8 grams. Your program should report the correct number of 1982-or-earlier coins (115) for either test case. Coins will never be so worn that the missing material accounts for more than 0.5 grams in the bag of 1000 coins. Hint: use a for loop to try every mixture of earlier and later pennies possible and compare the the given weight of the bag. Don't forget to include the weight of the bag itself.

##### Assignment

Write a complete class, Centalyzer, that will calculate the number of 1982-or-earlier and post-1982 coins in a bag as specified. You need a constructor that has a total bag weight (as a double) as a parameter. You will also need accessor methods to get the number of 1982-or-earlier and post-1982 coins in the bag.

Copyright © 2010 by Asylum Computer Services LLC |
Return to CS Labs |