return 0;
}
This is my code, I need to get all of the deposits and withdrawals to get different outputs, please bare with my messy post, I really need help
#include <iostream>
#include <iomanip>
usingnamespace std;
#define SIZE 3
int main()
{
double balance;
int deposit[SIZE];
int withdrawl[SIZE];
double interest;
double gainedInt;
double monthlyInt;
int num = 0;
double intBalance;
cout << "Please enter the initial balace: ";
cin >> balance;
intBalance = balance;
cout << "Please enter the annual interest rate: ";
cin >> interest;
monthlyInt = interest / 12;
for (num = 0; num < SIZE; num++)
{
cout << " Enter the total deposited: " << endl;
cin >> deposit[num];
cout << " Enter the total withdrawn: " << endl;
cin >> withdrawl[num];
if (deposit[num] > 0 && withdrawl[num] < balance + deposit[num])
{
balance = balance + deposit[num];
balance = balance - withdrawl[num];
gainedInt = balance*monthlyInt;
balance = balance + gainedInt;
}
else
{
cout << " You have entered an invalid number" << endl;
return 0;
}
}
cout << " Starting Balance: " << intBalance << endl;
cout << " Current Balance: " << balance << endl;
cout << " Annual interest rate (%): " << interest << endl;
for (num = 0; num < SIZE; num++)
{
cout << "Month " << num+1 << " Deposit:" << deposit[num] << " , Withdrawal " << withdrawl[num] << endl;
}
return 0;
}
Here is output
Please enter the initial balace: 12000
Please enter the annual interest rate: 12
Enter the total deposited:
1000
Enter the total withdrawn:
1000
Enter the total deposited:
1000
Enter the total withdrawn:
1000
Enter the total deposited:
2000
Enter the total withdrawn:
1000
Starting Balance: 12000
Current Balance: 98000
Annual interest rate (%): 12
Month 1 Deposit:1000 , Withdrawal 1000
Month 2 Deposit:1000 , Withdrawal 1000
Month 3 Deposit:2000 , Withdrawal 1000