Sunday, December 02, 2012

Bill calculation in C++


#include<iostream>


using namespace std;
class customer {
int a;
public:
int e,u,b,d,n;


void domestic(){
if(u<=100){
b=5*u; } if(u>100&&u<=300) {
b=8*u+100;}
if(u>100&&u<=300) {
b=10*u+230;}
} void date(){
if(d>=10){
b=b+200; } }
void showbill(){
cout<<"\nCustomer number: "<<n;
cout<<"\n Numbers of unit consumed: "<<u;
cout<<"\n Today date: "<<d;
cout<<"\nYour bill is Rs: "<<b;
}void commercial(){
b=u*15;
} void info() {
cout<<"\nEnter your customer number: ";  cin>>n;
cout<<"\nEnter your numbers of unit consumed: ";  cin>>u;
cout<<"\nEnter  today date: ";  cin>>d;  }
};
int main(){int e;
cout<<"Enter 1 for domestic user,2 for commercial user: ";
cin>>e;
customer s;
switch(e)
{ case 1:
cout<<" you are domestic user";
break;
case 2:
cout<<"you are commercial user";
break;
default:
cout<<"you entered a invaild choice";

return 0; }
s.info();
if(e==1){
s.domestic();
}
if(e==2){
s.commercial();
}
s.date();
s.showbill();

}

No comments:

Post a Comment