I need help!!! As soon as possible please!!!

Here is the problem:

Write a program that calculates the balance of a savings account at the end of a threemonth
period. It should ask the user for the starting balance and the annual interest rate. A
loop should then iterate once for every month in the period, performing the following:
A) Ask the user for the total amount deposited into the account during that month.
Do not accept negative numbers. This amount should be added to the balance.
B) Ask the user for the total amount withdrawn from the account during that
month. Do not accept negative numbers or numbers greater than the balance
after the deposits for the month have been added in.
C) Calculate the interest for that month. The monthly interest rate is the annual
interest rate divided by 12. Multiply the monthly interest rate by the average of
that month’s starting and ending balance to get the interest amount for the
month. This amount should be added to the balance.
After the last iteration, the program should display a final report that includes the following
information:
• starting balance at the beginning of the three-month period.
• total deposits made during the three months
• total withdrawals made during the three months
• total interest posted to the account during the three months
• final balance.


I need to solve it using a class. Please help. I have this so far but it brings out many errors and is incomplete.

#include<iostream>
using namespace std;

class Balance
{
private:
int Balance;
int monthInterestrate;

public:
double totalBalance ()
{return totalBalance = Balance + (deposit+withdraw) ;}

double getwithdraw()

{return Balance-=withdraw ;}

double getdeposit()

{return Balance+=deposit;}

double computeInterest()

{return Balance*monthInterestrate; }
};

int main ()
{
Balance balance1,
balance2,


balance1.getwithdraw();
balance2.getdeposit();

cout<<"Enter the amount withdrawn in three months: " <<balance1.getwithdraw()<<endl;
cout<<"Enter the amount deposited in three months: " <<balance2.getdeposit()<<endl;

system ("pause");
return 0;
}
All the errors I see are because your variables aren't defined.
Thanks for the reply...I've fixed it somewhat but I need some guidance on how to make it do exactly what the question is asking for. How do I get it to allow me to enter the values for each myself?

#include<iostream>
using namespace std;

class Account
{
private:
int Balance;
int monthInterestrate;
double deposit;
double withdraw;
double totalB;

public:

Account();
double totalBalance ()
{return totalB = Balance + (deposit+withdraw) ;}

double getwithdraw()

{return withdraw;}

void setwithdraw(double w)
{withdraw = w;}
double getdeposit()


{return deposit;}

void setdeposit(double d)
{deposit = d;}

double computeInterest()

{return Balance*monthInterestrate/12; }

void setInterest(double i)
{monthInterestrate = i;}
};

int main ()
{
Account balance1;
balance1.setwithdraw(0);
balance1.setdeposit(0);
balance1.setInterest(42);
balance1.getwithdraw();
balance1.getdeposit();
balance1.computeInterest();

cout<<"Enter the amount withdrawn in three months: " <<balance1.getwithdraw()<<endl;
cout<<"Enter the amount deposited in three months: " <<balance1.getdeposit()<<endl;

system ("pause");
return 0;
}

Account::Account()
{ totalB = 0 ;
withdraw = 0;
deposit = 0;
monthInterestrate = 0;}
Last edited on
Ok so I got it to let me enter the values myself...now I need the calculations part done...also how do I get rid of the zeroes???

#include<iostream>
using namespace std;

class Account
{
private:
int Balance;
int monthInterestrate;
double bal;
double deposit;
double withdraw;
double totalB;

public:

Account();
double totalBalance ()
{return totalB = Balance + (deposit+withdraw) ;}

double getbal()
{return bal;}
void setbal(double b)
{bal = b;}

double getwithdraw()

{return withdraw;}

void setwithdraw(double w)

{withdraw = w;}

double getdeposit()

{return deposit;}

void setdeposit(double d)
{deposit = d;}

double computeInterest()

{return Balance*monthInterestrate/12; }

void setInterest(double i)
{monthInterestrate = i;}
};

int main ()
{
Account balance1;
balance1.setbal(0);
balance1.setwithdraw(0);
balance1.setdeposit(0);
balance1.setInterest(0);
balance1.getbal();
balance1.getwithdraw();
balance1.getdeposit();
balance1.computeInterest();

int choice;
double Bal, dep, with, intrate;

cout<<"Enter the monthly interest rate: "<<balance1.computeInterest()<<endl;
cin>>intrate;
cout<<"Enter the initial balance: "<<balance1.getbal()<<endl;
cin>>Bal;
cout<<"Enter the amount withdrawn in three months: " <<balance1.getwithdraw()<<endl;
cin>>with;
cout<<"Enter the amount deposited in three months: " <<balance1.getdeposit()<<endl;
cin>>dep;

system ("pause");
return 0;
}

Account::Account()
{ totalB ;
bal ;
withdraw ;
deposit ;
monthInterestrate ;}
Topic archived. No new replies allowed.