Car Pay or Not pay
Car Pay or Not pay
Just open your c++ compiler Paste this code.
#include<iostream>
using namespace std;
class tollbath{
public:
int car ;
double money;
tollbath(){
}
tollbath(int c,double m):car(0),money(0.50)
{}
void payingcar(){
cout<<"enter car\n";
cin>>car;
cout<<"enter money\n";
cin>>money;
car=car++;
money=money+0.50;
}
void nopaycar(){
cout<<"enter car\n";
cin>>car;
cout<<"enter money\n";
cin>>money;
car=car++;
}
void display(){
cout<<"paying car"<<car<<"\nmoney"<<money<<"\nno pay car"<<car;
}
};
int main()
{
tollbath t;
t.payingcar();
t.display();
t.nopaycar();
t.display();
}
Just open your c++ compiler Paste this code.
#include<iostream>
using namespace std;
class tollbath{
public:
int car ;
double money;
tollbath(){
}
tollbath(int c,double m):car(0),money(0.50)
{}
void payingcar(){
cout<<"enter car\n";
cin>>car;
cout<<"enter money\n";
cin>>money;
car=car++;
money=money+0.50;
}
void nopaycar(){
cout<<"enter car\n";
cin>>car;
cout<<"enter money\n";
cin>>money;
car=car++;
}
void display(){
cout<<"paying car"<<car<<"\nmoney"<<money<<"\nno pay car"<<car;
}
};
int main()
{
tollbath t;
t.payingcar();
t.display();
t.nopaycar();
t.display();
}








0 comments: