Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- // make a program that calculates the year interest and monthly hence of a stereo system;
- double amount; // Amount typed in;
- double payment = 50; // Payment per month;
- double interestRate;
- double sum;
- int count = 0;
- double totalInterest;
- cout << "Input the cost of the item in the debpt : ";
- cin >> amount;
- if (amount <= 1000)
- cout << "----------------------------------------------------" << endl;
- do
- {
- count++;
- interestRate = amount * 0.015;
- amount = amount - payment + interestRate;
- sum += interestRate;
- if (amount < 0)
- {
- amount = 0;
- }
- cout.setf(ios::fixed);
- cout.setf(ios::showpoint);
- cout.precision(2);
- cout << "month : " << count << " - ";
- cout << "Interest paid: " << interestRate << " - ";
- cout << "Remainig debt: " << amount << endl;
- }
- while (amount > 0);
- cout << "----------------------------------------------------" << endl;
- if (amount > 1000)
- cout << "----------------------------------------------------" << endl;
- do
- {
- count++;
- interestRate = amount * 0.02;
- amount = amount - 50 + interestRate;
- sum += interestRate;
- if (amount < 0)
- {
- amount = 0;
- }
- cout.setf(ios::fixed);
- cout.setf(ios::showpoint);
- cout.precision(2);
- cout << "month : " << count << " - ";
- cout << "Interest paid: " << interestRate << " - ";
- cout << "Remainig debt: " << amount << endl;
- }
- while (amount > 0);
- cout << "----------------------------------------------------" << endl;
- cout << "Number of months: " << count << endl;
- }
Add Comment
Please, Sign In to add comment