I just did this and I am not sure I am doing this correctly.

You have purchased a stereo system that cost $1000 on the following credit plan: no payment down, an interest of 18% per year, and monthly payments of $50. The monthly payment of $50 is used to pay the interest and whatever is left is used to pay part of the remaining debt. Hence, the first month you pay 1.5% of $1000 in interest. That is $15 in interest. So, the remaining $35 is deducted from your debt, which leaves you with a debt of $965.00. And its asking for total payment and total interest.

#include <iostream.h>
#include <conio.h>

main()
{
   cout.setf(ios::fixed);
   cout.setf(ios::showpoint);
   cout.precision(2);

   double cost = 1000, annualInterestRate = 0.18, monthlyPayment = 50, monthlyRate, monthlyInterestRate;
   double monthlyInterest, towardsPrinciple, payment, totalPayment=0, totalInterest;

   while (cost > 0)
   {
      monthlyInterestRate = annualInterestRate / 12;
      monthlyInterest = cost * monthlyInterestRate;
      towardsPrinciple = monthlyPayment - monthlyInterest;
      cost = cost - towardsPrinciple;
      totalInterest = totalInterest + monthlyInterest;
      totalPayment = totalPayment + towardsPrinciple + monthlyInterest;

      if (cost + monthlyInterest >= monthlyPayment)
      	payment = monthlyPayment;
      else
      	payment = cost + monthlyInterest;

   }

   cout << "The total payment is " << totalPayment << endl;
   cout << "The total interest is " << totalInterest << endl;
   
   getch();
}

Thanks

Thanks for what? If you have a problem you need to explain what that is.

I just want to know if the steps are correct to find the total payment

How are you using the variable payment ?

:icon_rolleyes:

Did the program give you correct output? If no, it's definitely wrong. If yes, it might be right.

Wait .. So you're asking if this program is working correctly ?
Tip Check Your Total Interest

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.