#include <iostream>
using namespace std;
main()
{intx,charge;
float a,b,c;
cout<<"case 1<=2hours,case2<=3hours,case3<=4hours,case4<=5hours,case5>6hours\n";
cout<<"pls enter your time entry\n";
cin>>a;
   cout<<"pls enter your time exit\n";
   cin>>b;
   c=b-a;
   cout<<"no of hours park is\n"<<c;
   cout<<"pls enter no of case according to your no of parking hours\n";
   cin>>x;
   switch(x)
   {
       case 1:cout<< "the charge is RM2.00\n";break;
       case 2:cout<< "the charge is RM3.00\n";break;
       case 3:cout<< "the charge is RM4.00\n"; break;
       case 4:cout<< "the charge is RM5.00\n";break;
       case 5:cout<< "the charge is RM8.00\n";break;

default: cout<<"invalid hours of charge";break;
}
return 0;
}

Recommended Answers

All 4 Replies

OK, aside for the fact that the function header should be int main() and not just main(), what is the problem you are having?

ook thnks.but i still cannot run it properly because this pgrm should be test for
Time entry=08.20,10.30,11.15,12.01
time exit=09.15,13.45,16.30,19.45
can you help me to make it more correct?

try double instead of float

Convert and then subtract.I think that will solve yur problem.

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.