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.

Your class should have a constructor that receives an initial balance and use it to initialize the member variable.

a few hints on this line:

-The contructor ALWAYS has the same name as the class itself.
-You should add a second contructor to recieve the 'balance' (overloading)
-you should use a private member (type float) to write this value to ( float p - in the overloaded constructor write a code that checks if initial balance > 0.

Hope this helps you getting started.

a few hints on this line:
-The contructor ALWAYS has the same name as the class itself.
-You should add a second contructor to recieve the 'balance' (overloading)
-you should use a private member (type float) to write this value to ( float p - in the overloaded constructor write a code that checks if initial balance > 0.

Hope this helps you getting started.

Thanks for the reply, does what I have done so far look alright though?

Thanks for the reply, does what I have done so far look alright though?

Euhm, not really, sorry...
Where is your constructor? It should look like this Account(){}. Then you need an overloaded constructor to store the initial value in a membervalue, so: Account(float){}. In this overloaded constructor, make a function which checks if float > 0.

balance >==0;

What's that? What are you trying to do here?

Here's a classes tutorial by the one and only queen of daniweb.
You can google for more

p.s. Int main() is int main(void)

Euhm, not really, sorry...
Where is your constructor? It should look like this Account(){}. Then you need an overloaded constructor to store the initial value in a membervalue, so: Account(float){}. In this overloaded constructor, make a function which checks if float > 0.

What's that? What are you trying to do here?

Here's a good classes tutorial by the one and only queen of daniweb.

p.s. Int main() is int main(void)

lol, it's ok...you don't have to appologize I know I'm not very good at it, but that's why you take classes. So hopefully I'll start getting the hang of it.
but as far as balance >=0;
I don't know I was trying to set the member value as greater than or equal to zero....I knew it looked really wrong. lol, and again I really appreciate you trying to help me out.

I really appreciate you trying to help me out.

Ok, let's start simple with this line:

Your class should have a constructor that receives an initial balance and use it to initialize the member variable.

class Account
{
   private:
       float Inititial;
  public:
    Account();           //default constructor
    Account(float);     //overloaded constructor
};

Now type some code in the overloaded constructor that checks if the given float > 0 and then store it in Initial. One requirement down, alot to go ;)


[edit]
Please read this link, you'll find it useful

Ok, let's start simple with this line:

class Account
{
   private:
       float Inititial;
  public:
    Account();           //default constructor
    Account(float);     //overloaded constructor
};

Now type some code in the overloaded constructor that checks if the given float > 0 and then store it in Initial. One requirement down, alot to go ;)

regards Niek

[edit]
Please read this link, you'll find it usefull

You've alread helped me alot, but what is float inital? What does it do? Thanks again.

You've alread helped me alot, but what is float inital? What does it do?

Float is a variable-type (like int, double, char etc) with a floating point. Numbers like 1 and 19884 are int, numbers like 3,1415 and 0,0134 are float.
Float doesn't have an initial value so you have to give it one. float a= 0; You should read up on a lot of C, because if you don't know these basic things, Classes and OOP will be allmost impossible to understand.

Numbers like 1 and 19884 are int, numbers like 3,1415 and 0,0134 are float.

That would be 3.1415 and 0.01345 -- it was probably a typo by Nick.

You should read up on a lot of C, because if you don't know these basic things, Classes and OOP will be allmost impossible to understand.

As such no need to look up onto C. The basics of C and C++ are the same -- pointers, memory management, data types, structs, enums and the likes. C++ is what they call a functional superset of C.

That would be 3.1415 and 0.01345 -- it was probably a typo by Nick.

No it wasn't actually. In Holland we use the comma symbol in floatnumbers, I just forgot that this isn't standard :-|

As such no need to look up onto C. The basics of C and C++ are the same -- pointers, memory management, data types, structs, enums and the likes. C++ is what they call a functional superset of C.

That WAS a typo :D You're right offcourse.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.