Ch 5 Set 2 homework problems


1. The cost of operating a small Beverly Hills auto bumper gold-plating company can be given by this formula:
Cost = Units3 - 7 Units2  + $432
where Units stands for the number of bumpers that are gold-plated each day.

The company wants a program to determine how many bumpers should be produced each day to minimize operating costs.

Write a program that calculates and prints the cost for 1 unit, 2 units, 3 units, and so on, until a cost is calculated that is greater than the previous cost.

2. Write a program that will play the Hi-Lo guessing game. The user picks a secret number between 1 and 100. The computer tries to guess the number in less than five turns. When the computer makes a guess, the user enters a hint; the letter 'H' indicates the computer's guess was too high, the letter 'L' means the computer guessed too low. The program should use the hint to revise its guess. If the user enters the letter 'W' that means the computer guessed the number correctly and the computer should reply "I won.". If the computer takes 5 guesses without winning it should print a message "I lost."


3. Monica Martin makes $10,000 per year at her part-time job. Her boss offers Monica a raise but she must choose one of the following two options:
  1.  a thousand-dollar bonus right away followed by a ten percent salary increase every year.
  2.  a salary increase of one-twelfth of ten percent each month (and no bonus).
Write a program to aid Monica in making her decision.  Display a three column output that shows for each successive year the year number, and the salary for each of the two options.  The program should terminate when the salary for option two becomes greater than that for option one.

Notes: 
  1. You should never use a floating point variable to represent money, but we will make an exception for this assignment.
  2. The solution will require a nested loop.