#include<iostream.h>
#include<conio.h>
float minfee = 5;
int penalty1=1,penalty2=5,penalty3=10;
class parking{
int vtype;
char vno[20];
float days,charges,entrytime,exittime,hours;
void chargecount();
public:
void getreceipt();
void setreceipt();
};
void parking::setreceipt(){
cout<<"Enter vehicle type"<<endl;
cin>>vtype;
cout<<"Enter vehicle number"<<endl;
cin>>vno;
cout<<"Enter entry time"<<endl;
cin>>entrytime;
cout<<"Enter exit time"<<endl;
cin>>exittime;
cout<<"Enter Parking Days"<<endl;
cin>>days;
chargecount();
}
void parking::chargecount(){
if(exittime>=entrytime)
hours=exittime-entrytime;
else
hours=exittime+(24-entrytime);
if(days>=1)
hours=hours+days*24;
switch(vtype){
case 1:
if(hours<24)
charges=hours*10;
else
charges=24*10+(hours-24)*penalty1;
break;
case 2:
if(hours<24)
charges=hours*20;
else
charges=24*20+(hours-24)*penalty2;
break;
case 3:
if(hours<24)
charges=hours*50;
else
charges=24*50+(hours-24)*penalty3;
break;
}
}
void parking::getreceipt(){
cout<<"vehicle type=";
if(vtype==1)cout<<"bike or scooter"<<endl;
else
{
if(vtype==2) cout<<"car or Loading 4 wheelers"<<endl;
else cout<<"bus or truck"<<endl;
}
cout<<"vehicle number= "<<vno<<endl;
cout<<"Total charge="<<charges<<endl;
}
void main(){
parking p;
p.setreceipt();
p.getreceipt();
getch();
}
#include<conio.h>
float minfee = 5;
int penalty1=1,penalty2=5,penalty3=10;
class parking{
int vtype;
char vno[20];
float days,charges,entrytime,exittime,hours;
void chargecount();
public:
void getreceipt();
void setreceipt();
};
void parking::setreceipt(){
cout<<"Enter vehicle type"<<endl;
cin>>vtype;
cout<<"Enter vehicle number"<<endl;
cin>>vno;
cout<<"Enter entry time"<<endl;
cin>>entrytime;
cout<<"Enter exit time"<<endl;
cin>>exittime;
cout<<"Enter Parking Days"<<endl;
cin>>days;
chargecount();
}
void parking::chargecount(){
if(exittime>=entrytime)
hours=exittime-entrytime;
else
hours=exittime+(24-entrytime);
if(days>=1)
hours=hours+days*24;
switch(vtype){
case 1:
if(hours<24)
charges=hours*10;
else
charges=24*10+(hours-24)*penalty1;
break;
case 2:
if(hours<24)
charges=hours*20;
else
charges=24*20+(hours-24)*penalty2;
break;
case 3:
if(hours<24)
charges=hours*50;
else
charges=24*50+(hours-24)*penalty3;
break;
}
}
void parking::getreceipt(){
cout<<"vehicle type=";
if(vtype==1)cout<<"bike or scooter"<<endl;
else
{
if(vtype==2) cout<<"car or Loading 4 wheelers"<<endl;
else cout<<"bus or truck"<<endl;
}
cout<<"vehicle number= "<<vno<<endl;
cout<<"Total charge="<<charges<<endl;
}
void main(){
parking p;
p.setreceipt();
p.getreceipt();
getch();
}
No comments:
Post a Comment