How would I fix this?

How would I fix this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <iomanip> // Required for setw() setprecision(), fixed.
#include <math.h>
using namespace std;

int main()
{
    //Goal, enter in the month balance, then have it multiplied by interest, the $500 payment stays the same
    //Will still ask user for initial payment for the directions purpose
    
   cout << "Monthly Balance: ";
   int month_pay;
   cin >> month_pay;
    
   cout << endl;
   int int_rate;
   cin >> int_rate;
   
   cout << endl;
   int bal_pay;
   cin >> bal_pay;
    
   double month = month_pay;
    //Assign a month balance
    
   double interest = 0.01*month_pay;
    // 1% interest a month
    
   double payment = 500.00;
    //initial balance payment 
    
    cout << "Month Balance = " << setprecision(8) << month << "\n";
    cout << "Total Interest = " << interest << "\n";
    cout << "Initial Payment = " << payment << "\n"; 
  
    
}



To achieve a table (with setprecision and equal column widths) like this?:

Month Balance Interest Payment
1 $ 10050.00 $ 100.50 $ 500.00
2 $ 9650.5 $ 96.51 $ 500.00
3 $ 9247.01 $ 92.47 $ 500.00
4 $ 8839.48 $ 88.39 $ 500.00
Last edited on
Topic archived. No new replies allowed.