help me please!!!

question:


(Account Class) Create an Account class that a bank might use to represent customers’ bank accounts. Include a data member of type int to represent the account balance. [Note: In subsequent chapters, we’ll use numbers that contain decimal points (e.g., 2.75)—called floating-point values— to represent dollar amounts.] Provide a constructor that receives an initial balance and uses it to initialize the data member. The constructor should validate the initial balance to ensure that it’s greater than or equal to 0. If not, set the balance to 0 and display an error message indicating that the initial balance was invalid. Provide three member functions. Member function credit should add an amount to the current balance. Member function debit should withdraw money from the Account and ensure that the debit amount does not exceed the Account’s balance. If it does, the balance should be left unchanged and the function should print a message indicating "Debit amount exceeded account balance." Member function getBalance should return the current balance. Create a program that creates two Account objects and tests the member functions of class Account.



solving: i did but make error i do not know!!


#include <iostream>

using namespace std;

//creating account class
class Account
{
public:
Account ( int );
void setBalance( int );
int getBalance();
void debitBalance( int );
void creditBalance( int );
private:
int balance; // bank account balance name
};


#include <iostream>

using namespace std;

#include "Account.h"

//initialization with constructor, with supplied args
Account::Account ( int initialBalance )
{
if (initialBalance >= 0)
setBalance ( initialBalance );
cout << "Account balance set without any problem" << endl;

if (initialBalance < 0)
{
balance = 0;
cout << "Account balance cannot be negative. Account amount set as 0" << endl;
}
}

void Account::setBalance(int newbalance)
{
balance = newbalance;
}

void Account::debitBalance( int debit )
{
if (debit > balance)
cout << "Your balance is not enough!\n";
else
{
balance = balance - debit;
}

}
void Account::creditBalance( int credit)
{
balance =balance + credit;
}
int Account::getBalance()
{
return balance;
}




include <iostream>
#include "Account.h"
using namespace std;



int main()
{
Account account1( 1111 );
Account account2( -1111 );

int choise;
int accountNo;
int debAmount;
int credAmount;

//display initial balances

cout << "Initial balance of account1 is " << account1.getBalance() << endl;


cout << "Initial balance of account2 is " << account2.getBalance() << endl;



cout<<"please choice your account"<<endl;



cout<<"1-myaccount1"<<endl;



cout<<"2-myaccount2"<<endl;



cin>> accountNo;


switch(accountNo){

case 1:
cout << "\nPlease select the transaction (enter the number):" << endl;
cout << "1. Balance Inquiry" << endl;
cout << "2. Debit" << endl;
cout << "3. Credit" << endl;
cin>>choise;
switch (choise){
case 1:
cout << "account1 balance: " << account1.getBalance() << endl;
break;
case 2 :
cout << "enter debit amount: " << endl;
cin >> debAmount;

account1.debitBalance(debAmount);

cout << "current balance is " << account1.getBalance() << endl;
break;
case 3:

cout << "enter credit amount: " << endl;
cin >> credAmount;

account1.creditBalance(credAmount);
cout << "current balance is " << account1.getBalance() << endl;
break;

}
break;
case 2 :


cout << "\nPlease select the transaction (enter the number):" << endl;
cout << "1. Balance Inquiry" << endl;
cout << "2. Debit" << endl;
cout << "3. Credit" << endl;
cin>>choise;


switch (choise){
case 1:
cout << "account2 balance: " << account2.getBalance() << endl;
break;
case 2 :
cout << "enter debit amount: " << endl;
cin >> debAmount;

account1.debitBalance(debAmount);
cout << "current balance is " << account2.getBalance() << endl;
break;
case 3:

cout << "enter credit amount: " << endl;
cin >> credAmount;
account2.creditBalance(credAmount);
cout << "current balance is " << account2.getBalance() << endl;
break;

}
}
}






it make error

Error 1 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

Error 2 error LNK1120: 1 unresolved externals


what is the problem please help me ! for solving

You posted this question in an other topic.

And just as I told you before: USE [ code ] and [ /code ] to make your program code readable!

And please dont repost the same question in a new topic


EDIT:

Read this before posting http://www.cplusplus.com/forum/articles/1295/
Last edited on
well first get rid of the extra #include <iostream>'s and the extra using namespace std;'s and #include "Account.h"'s. Then post the Account.h file using code tages, and repost the original file with code tags. Hint its the <> button on the right side of the screen.
closed account (3qX21hU5)
For warning to everyone the OP is unwilling to take any advice that is given him and seems to be looking for someone to do his homework for him. I believe this is his 3rd topic he posted about this question (All totally ignoring advice to use codetags) and Hashimatsu and others have tried to help him correct it but he just ignores their advice.

So please do not give this guy a fixed version of his code so he can copy and paste ;P


Signed Zereo ~ Stopping all homework fraud from his couch while eating pizza.
Topic archived. No new replies allowed.