Hello, this is my first time posting here, so I'm new to the site and C++. First off I'm not asking anyone to do my homework, but I'am having some homework troubles. I've been working at it for awhile and I'm not really sure where to turn next. so any help would be appreciated.
Here's what I'm supposed to do:
Create a program with a class called Account. The class should include one member variable called balance of type float that represents the account balance. Your class should have a constructor that receives an initial balance and use it to initialize the member variable. The constructor should validate the initial balance to ensure that it is greater than or equal to 0. If not the balance should be set to 0 the constructor should display an error message, indicating the initial balance was invalid. The class should have five member functions:
a.) void setBalance(float b)---- set the value of the member variable balance
b.) float getBalance()----returns the value of the membe variable
c.) void credit(float c)----add amount to the current balance
d.) void debt(float d)-----
e.) void showAccountInfo()----display the account balance
And it's supposed to be in 3 files, .cpp, .cpp, and .h
Here's my main code:
#include<iostream>
#include<string>
#include"Account1.h"
using namespace std;
Int main()
{
float withdraw,deposit;
Account myAccount(100.00);
cout<<"Enter the amount you would like to withdraw:"<<endl;
cin>>withdraw;
myAccount.debt(withdraw);
cout<<"Your balance now is "<<endl;
myAccount.showAccountInfo();
cout<<endl;
cout<<"Enter the amount you would like to deposit:"<<endl;
cin>>deposit;
myAccount.credit(deposit);
cout<<"Your balance now is "<<endl;
myAccount.showAccountInfo();
cout<<endl;
return 0;
}
and here's my .h file
#include<iostream>
#include<string>
#include"Account.h"
using namespace std;
class Account
{
public:
floatBalance(float b)
{
balance = b;
}
void setBalance( float b )
{
balance >==0;
}
float getBalance()
{
return balance;
}
void credit( float c )
{
c=
}
void debt( float d)
{
}
void showAccountInfo()
private:
sorry it's so long, and you can see where I'm stuck in places. I'm not exactly sure how to declare a member variable called balance of float type. So any advice or anything that might put me in the right direction would definitely help. I put the main file just to see if that was all setup right, I'm mainly having issues with the .h file. Thanks for the help.