while ( condition )
statement ;
for ( init ; condition ; incr )
statement ;
do
statement
while ( condition ) ;
The while loops and for loops are the most common loops used. All for and do-while loops can be written as while loops (the simpliest form of the looping statements), but rarely does a program contain only while loops.
// printout the column headings
cout << " :";
for (i = 1; i <= 10; i++)
{
cout.width(4);
cout << i;
}
cout << endl;
// print out 10 rows with a row heading
// outer loop
for (i = 1; i <= 10; i++)
{
cout.width(4);
cout << i << ":"
// print out the products for the row and column values
// inner loop
for (j = 1; j <= 10; j++)
{
cout.width(4);
cout << i*j;
}
cout << endl;
}
You may turn in the assignment to your TA during lab or place it in his mailbox in 905 SEO. It is suggested that you place it in his mailbox just in case you are unable to attend lab. You are to hand in a print out of your program to do the following to your TA.
Create a C++ program on your UIC icarus account that will calculate the number of months needed to payoff a loan and the amount of interest paid on the loan. Your program should prompt the user for:
Once you know the monthly payment is large enough, use a loop to calculate the amount of interest and the size of the debt after each month. (You may wish to print out these values, but you are not required to.) Note the last payment may be less and the normal monthly payment amount.
To understand how this is done, let us look at the following example. Assume you have a loan of $1000, with a monthly payment of $50 and monthly interest rate of 1.5%.
Hand in a print out of your program to your TA.