Guest User

Untitled

a guest
Nov 16th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.13 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     // make a program that calculates the year interest and monthly hence of a stereo system;
  8.     double amount; // Amount typed in;
  9.     double payment = 50; // Payment per month;
  10.     double interestRate;
  11.     double sum;
  12.     int count = 0;
  13.     double totalInterest;
  14.  
  15.  
  16.     cout << "Input the cost of the item in the debpt : ";
  17.     cin >> amount;
  18.         if (amount <= 1000)
  19.         cout << "----------------------------------------------------" << endl;
  20.             do
  21.             {
  22.               count++;
  23.               interestRate = amount * 0.015;
  24.               amount = amount - payment + interestRate;
  25.               sum += interestRate;
  26.  
  27.               if (amount < 0)
  28.                 {
  29.                     amount = 0;
  30.                 }
  31.                 cout.setf(ios::fixed);
  32.                 cout.setf(ios::showpoint);
  33.                 cout.precision(2);
  34.                 cout << "month : " << count << " - ";
  35.                 cout << "Interest paid: " << interestRate << " - ";
  36.                 cout << "Remainig debt: " << amount << endl;
  37.  
  38.             }
  39.             while (amount > 0);
  40.             cout << "----------------------------------------------------" << endl;
  41.            if (amount > 1000)
  42.         cout << "----------------------------------------------------" << endl;
  43.             do
  44.             {
  45.               count++;
  46.               interestRate = amount * 0.02;
  47.               amount = amount - 50 + interestRate;
  48.               sum += interestRate;
  49.  
  50.               if (amount < 0)
  51.                 {
  52.                     amount = 0;
  53.                 }
  54.                 cout.setf(ios::fixed);
  55.                 cout.setf(ios::showpoint);
  56.                 cout.precision(2);
  57.                 cout << "month : " << count << " - ";
  58.                 cout << "Interest paid: " << interestRate << " - ";
  59.                 cout << "Remainig debt: " << amount << endl;
  60.  
  61.             }
  62.             while (amount > 0);
  63.             cout << "----------------------------------------------------" << endl;
  64.             cout << "Number of months: " << count << endl;
  65.  
  66.  
  67.  
  68.  
  69.     }
Add Comment
Please, Sign In to add comment