How would I fix this?

How would I fix this code:

 ``1234567891011121314151617181920212223242526272829303132333435363738`` ``````#include #include // Required for setw() setprecision(), fixed. #include 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.