At the beginning of the program, add
#include <string.h>
Now in main()
add two more variables:
int price;
char car_model[100];
Then, inside the switch()
, instead of printing the information, you set these two values, then print them after the end of the switch()
:
switch(d)
{
case 1:
strncpy(car_model, "ZEN", 100);
price = 4000;
break;
case 2:
strncpy(car_model, "OMNI", 100);
price = 5000;
break;
case 3:
strncpy(car_model, "Volkswagen Polo", 100);
price = 15000;
break;
}
printf("\n You have selected %s | Cost %drs per day \n", car_model, price);
break;
Do the same for the other two inner switch()
statements and you should be good to go. You then can use these variables at the end of the program as well.
Mind you, there are all sorts of ways to simplify this program further; I expect you'll see some of them if you look.