When ever run this program, I can't get the total price right and I tried it so many times but failed. Can anyone help me where or how to fix this mistake. This is my mini project for my assessment :(.
using namespace std;
int main ()
{
char name [30], ic [20];
char day [10], date [10];
char package, vehicle_code;
char number_plate [10];
double price, total;
cout<<"\n\n ===================================================================";
cout<<"\n |-----------------------------------------------------------------|";
cout<<"\n | |";
cout<<"\n |____________________WELCOME TO BOOK PLUS PARKING_________________|";
cout<<"\n | |";
cout<<"\n |-----------------------------------------------------------------|";
cout<<"\n ===================================================================";
cout<<"\n\n Please enter your name:";
cin.getline (name, 30);
cout<<"\n Please enter your IC number:";
cin.getline (ic,20);
cout<<"\n\n ===============================================================================================";
cout<<"\n | DAY | TYPE OF VEHICLE | PACKAGE PROVIDED |PRICE (RM) |";
cout<<"\n -----------------------------------------------------------------------------------------------";
cout<<"\n | Weekday | Car | A (1/2 hour) | 5.50 |";
cout<<"\n | | | B (3/4 hour) | 8.30 |";
cout<<"\n | | | C (5+ hour) | 10.00 |";
cout<<"\n -----------------------------------------------------------------------------------------------";
cout<<"\n | | Motorcycle | A (1/2 hour) | 3.50 |";
cout<<"\n | | | B (3/4 hour) | 5.30 |";
cout<<"\n | | | C (5+ hour) | 8.00 |";
cout<<"\n -----------------------------------------------------------------------------------------------";
cout<<"\n | Weekend | Car | A (1/2 hour) | 6.50 |";
cout<<"\n | | | B (3/4 hour) | 9.30 |";
cout<<"\n | | | C (5+ hour) | 11.00 |";
cout<<"\n -----------------------------------------------------------------------------------------------";
cout<<"\n | | Motorcycle | A (1/2 hour) | 4.50 |";
cout<<"\n | | | B (3/4 hour) | 6.30 |";
cout<<"\n | | | C (5+ hour) | 9.00 |";
cout<<"\n ===============================================================================================";
cout<<"\n\n =====================================================================";
cout<<"\n | TYPE OF VEHICLE | VEHICLE CODE |";
cout<<"\n ---------------------------------------------------------------------";
cout<<"\n | Car | 'C' |";
cout<<"\n -------------------------------------------------------------------- ";
cout<<"\n | Motorcycle | 'M' |";
cout<<"\n =====================================================================";
cout<<"\n\n Please enter day of booking:";
cin.getline(day,10);
cout<<"\n Please enter date of booking:";
cin.getline (date,10);
cout<<"\n Please enter vehicle code:";
cin>>vehicle_code;
cout<<"\n Please choose package:";
cin>>package;
if (strcmp (day,"Monday")|| (day, "Tuesday")|| (day, "Wednesday")|| (day, "Thursday")|| (day,"Friday"))
{
if (vehicle_code == 'C')
{
if (package == 'A')
{
price = 5.50;
}
else if (package == 'B')
{
price = 8.30;
}
else if (package == 'C')
{
price = 10.00;
}
else
{
cout<<"\n INVALID PACKAGE!";
}
}
else if (vehicle_code == 'M')
{
if (package == 'A')
{
price = 3.50;
}
else if (package == 'B')
{
price = 5.30;
}
else if (package == 'C')
{
price = 8.00;
}
else
{
cout<<"\n INVALID PACKAGE!";
}
}
else
{
cout<<"\n INVALID VEHICLE CODE!";
}
}
else if (strcmp (day, "Saturday")|| (day,"Sunday"))
{
if (vehicle_code == 'C')
{
if (package == 'A')
{
price = 6.50;
}
else if (package == 'B')
{
price = 9.30;
}
else if (package == 'C')
{
price = 11.00;
}
else
{
cout<<"\n INVALID PACKAGE!";
}
}
else if (vehicle_code == 'M')
{
if (package == 'A')
{
price = 4.50;
}
else if (package = 'B')
{
price = 6.30;
}
else if (package = 'C')
{
price = 9.00;
}
else
{
cout<<"\n INVALID! PACKAGE!";
}
}
else
{
cout<<"\n INVALID VEHICLE CODE!";
}
}
else
{
cout<<"\n INVALID DAY!";
}
total = price;
cout<<"\n TOTAL PAYMENT (RM) :"<<total;
}