Exercise Set#5

on Monday, February 8, 2010
Exercise 1 --- Check Charge
A bank has the following rule: if a customer has more than $1000 dollars in their checking account or more than $1500 dollars in their savings account, then there is no service charge for writing checks. Otherwise there is a $0.15 charge per check. Write a program that asks for the balance in each account and then writes out the service charge.

Exercise 2 --- Tire Pressure
The front tires of a car should both have the same pressure. Also, the rear tires of a car should both have the same pressure (but not neccessarily the same pressure as the front tires.) Write a program that accepts the pressure of the four tires and writes a message that says if the inflation is OK or not.

Right front pressure: 38
Left front pressure: 38
Right rear pressure: 42
Left rear pressure: 42

Inflation is OK

Exercise 3 --- More Tire Pressure
Its not enough that the pressures are the same in the tires, but the pressures must also be within range. Modify the program in exercise 1 so that it also checks that each tire has a pressure between 35 and 45.

Right front pressure: 32
Warning: pressure is out of range

Left front pressure: 32
Warning: pressure is out of range

Right rear pressure: 42
Left rear pressure: 42

Inflation is BAD

If there have been any warnings, write out a final error message.

Exercise 4 --- The Pressure is Building
Tires don't have to have exactly the same pressure. Modify the program for exercise 2 so that the front tires can be within 3 psi of each other, and the rear tires can be within 3 psi of each other.

Right front pressure: 35
Left front pressure: 37
Right rear pressure: 41
Left rear pressure: 44

Inflation is OK

2 comments:

ŇÃŜĮŘ ÃββÃŜ said...

Nys Blog
For More programming exercises ,visit this blog
programmingexercises

ŇÃŜĮŘ ÃββÃŜ said...

programming exercises

Post a Comment