//Allan Clark Alintrst.cpp// //Oct 15/02// //To make an interest table// #include //The library call for input/output// #include //The library call for input/output manipulation// #include //The library call for clrscr()// #include //The library call used to manipulate string variables. (strcpy)// #include //The library call to use math equations (sqrt) // #include //The library call to acquire the system's date// int main(void) { char yes; // Declaration of Local Variables // int yearstart, yearend, yearcount; double principle, rate, interest, intertotal; //Fowler Statement// cout << endl << endl; cout << " ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*" << endl; cout << " ~ This Program will make an interest table *" << endl; cout << " ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*" << endl; cout << endl; cout << " // Allan Clark - Programmer //" << endl << endl; cout << " Press Any Key to Continue"; getch(); // gets character // start: clrscr(); //Clears the fowler screen and goes to the input screen// time_t t=time(NULL); cout << "\t" << ctime(&t)<< endl << endl; //Displays the time// cout << endl << endl; cout << "\t\tInterest Analysis" << endl; cout << "\t\t~~~~~~~~~~~~~~~~~" << endl; cout << endl; cout << " How many years will the investment be left in the term deposit?: "; cin >> yearend; cout << endl << endl; cout << " What is the principle of the original investment?: $"; cin >> principle; cout << endl << endl; if(principle < 0) //If the principle is lower than zero then the program restarts// { goto start; } cout << " What will be the rate of interest given on the investment?: "; cin >> rate; if(rate < 0) //If the rate is lower than 0 then the program restarts// { goto start; } if(rate > 100) //If the rate is larger than 100 then the program restarts// { goto start; } clrscr(); cout << "\t" << ctime(&t)<< endl << endl; //Displays the time// cout << " \t\t Investment Analysis Chart Overview" << endl; cout << " \t\t ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl << endl; yearcount = yearend + 1; cout << " Time (Year End) \tPrinciple Accrued \t Interest Earned: " << endl; cout << " ~~~~~~~~~~~~~~~ \t~~~~~~~~~~~~~~~~~ \t ~~~~~~~~~~~~~~~~ " << endl; yearstart = 1; for(yearcount = yearstart; yearcount <= yearend; yearcount++) { principle = principle + interest; // accrues principal and interest earned for the year interest = principle * rate * 0.01 * 1; // calculate the interest for a one year period intertotal = intertotal + interest; // totals the yearly interest for the final summary cout << setiosflags(ios:: fixed | ios:: right); cout << setprecision(1); cout << setw(10) << yearcount << setprecision(2) << setw(30) << principle; cout << setw(25) << intertotal; cout << endl; } cout << endl << "\t\t\t !! * Thank You * !!" << endl << endl; cout << "\t Do you wish to make another report? (y/n): "; cin >> yes; if(yes == 'y') // If statement that asks user if (s)he wants to make another report // { goto start; } if(yes == 'n') { return 0; } }