#include <iostream>
#include<cmath>
using namespace std;
int main()
{int x;
char time, charge;
cout<<"case 1<=2hours,case 2<=3hours,case 3<=4hours,case 4<=5hours,case 5>6hours";
cout<<"pls enter your time entry";
cin>>"time";
cout<<"pls enter your time exit";
cin>>time;
switch(hours_charge)
{
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";
}
cout<<"no of hours parked is"<<"x";
cin>>"x";
cout<<"the charge is"<<"RM";
cin>>"x*case">>"="
This line makes no sense:
cin >> "time"; // "time" is a string -- NOT your variable time.
You can not store the two different values in one variable.
cout << "pls enter your time entry";
cin >> time; // time entry is now stored in variable time
cout << "pls enter your time exit";
cin >> time; // time exit is now stored in variable time -- time entry is GONE.
Your switch is using a non-existant variable hours_charge. I assume you meant charge:
switch(charge)
{
...snip...
However, you've never given charge a value, so it will have undefined behaviour (the value will be whatever was stored in that memory before it was used for your variable).
You probably want to do something like this before your switch:
cout << "pls enter your entry time";
cin >> entry_time;
cout << "pls enter your exit time";
cin >> exit_time;