Write a C++ object oriented program which computes interest on a credit card bal
ID: 3549895 • Letter: W
Question
Write a C++ object oriented program which computes interest on a credit card balance. The task is done with a function that accepts initial balance, monthly interest rate, number of months for which the interest must be paid. The value returned is the interest due. Allow repeat at user's option. Note Interest is compounded. Function is to be embed in a program that acquires these values and outputs the interest due. Repeat of computation at users option is to be allowed.
Use Object Oriented design.
I'm having trouble with my header file and the .cpp file that goes along with it.
I'm using codeblocks with the gnu compiler
I need 3 files, the main.cpp, the .h header file, and the .cpp file for the implementation. Thank you for any help.
Explanation / Answer
#include <iomanip>
#include <iostream>
double Calculate (double,double,double);
int main()
{
double principle, rate, months;
int choice;
system("cls");
std::cout << "How much do you owe?" << std::endl;
std::cout << "$";
std::cin >> principle;
std::cout << "What is your interest rate? (in percent form)" << std::endl;
std::cin >> rate;
std::cout << "How many months do you plan to take to pay off your debt?" << std::endl;
std::cin >> months;
std::cout << "Interest: $" << (Calculate(principle,rate,months) - principle) << std::endl;
std::cout << "Total: $" << Calculate(principle,rate,months) << std::endl;
std::cout << "Do you want to calculate your interest again?" << std::endl;
std::cout << "1.Yes" << std::endl;
std::cout << "2.No" << std::endl;
std::cin >> choice;
if (choice == 1)
{
main();
}
return 0;
}
double Calculate(double principle, double rate, double months)
{
for (months;months > 0;months--)
{
principle += principle * (rate/100);
}
return principle;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.