#include"Gradebook.h"
 #include<iostream>
 #include<conio.h>
 #include<string>
 using namespace std;

 Gradebook::Gradebook( int balance)


     {


 if(balance>=0)
 {
 balance=balance;
 Withdraw(balance);
 }
 else
 {
 cout<<"Balance can not be negative\n";
 }

 }
 void Gradebook::Withdraw(int)
 {
 cout<<"Enter amount to withdraw\n";
 cin>>credit;
 if(balance>credit)
 {
 cout<<"invalid credit greater than balance\n";
 }
 if (balance<credit)
 {
 int total=balance-credit;

 cout<<"Current balance:"<<total;
 }
 getch();
 }

#include<string>
#include<iostream>
using namespace std;


class Gradebook
{
public:

Gradebook(int balance);
void Withdraw(int);
private:
    int credit;
    int balance;
    int total;
};









#include"Gradebook.h"
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{

    cout<<"Enter intial amount\n";
    int intialamount;
    cin>>intialamount;
    Gradebook myGradebook(intialamount);


}

Recommended Answers

All 2 Replies

Do you have a question?

Your indentaion is very poor. work on that first ok?

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.