< previous page page_91 next page >

Page 91
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
const float DEBT = 300.0;     // Original value owed
const float PAYMT = 22.4;     // Payment
const float INTR = 0.02;      // Interest rate

int main()
{
    float charg;    // Interest times debt
    float reduc;    // Amount debt is reduced
    float remain;   // Remaining balance

    charg = INTR * DEBT;
    reduc = PAYMT - charg;
    remain = DEBT - reduc;
    cout < Payment:  < PAYMT
         <  Charge:  < charg
         <  Balance owed:  < remain < endl;
    return 0;
}
5. Enter the following program into your computer and run it. Add comments, using the pattern shown in Exercise 4 above. (Notice how hard it is to tell what the program does without the comments.)
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
#include <iostream.h>

const int T_COST = 1376;
const int POUNDS = 10;
const int OUNCES = 12;

int main()
{
    int   tot0z;
    float uCost;

    tot0z = 16 * POUNDS;
    tot0z = tot0z + OUNCES;
    uCost = T_COST / tot0z;
    cout < Cost per unit:  < uCost < endl;
    return 0;
}
6. Change the program in Exercise 5 above so that it prints the total cost and total weight (labeled appropriately) before printing the cost per unit.
Programming Problems
1. Write a C++ program that will print your initials in large block letters, each letter made up of the same character it represents. The letters should be a minimum of

 
< previous page page_91 next page >