Code:
#include <stdio.h>
int main (int argc, const char * argv[])
{
int location, vehicle, weekday, peak, km, days;
float price, insurance;
printf("Please choose a location(1: Toronto 2: Missisauga 3: Milton):\n");
scanf("%d", &location);
switch (location) {
case 1:
printf("Which type of car(1: Pickup Truck 2: Cargo Truck 3: 10' Truck 4: 14' Truck 5: 20' truck):\n");
scanf("%d", &vehicle);
if (vehicle==5){
printf("not avail.\n");
break;}
printf("Enter weekday (1-Mon, 2-Tues 3-Weds,4-Thurs, 5-Fri, 6-Sat, 7-Sun):\n");
scanf("%d", &weekday);
if (weekday > 4){
peak = 1;}
else peak == 0;
printf("Enter number of KMs driven:\n");
scanf("%d", &km);
printf("Would you like insurance:(1-Yes/0-No)\n");
scanf("%d", &insurance);
if (insurance==1){
printf("How many days will you have the car for?\n");
scanf("%d", &days);
insurance=30*days;}
else {insurance==0;}
if (vehicle==1 && peak==1){
price=0.50*km+15;}
if (vehicle==1 && peak==0){
price=0.50*km+12.50;}
printf("Total is: %lf Insurance: %lf\n",price,insurance);
}
/*
break;
case 2:
printf("you chose green color\n");
break;
case 3:
printf("you chose blue color\n");
break;
default:
printf("you did not choose any color\n");
*/
}
Compiling fine, just the the maths not making sense.
IGNORE THE COMMENT AT BOTTOM.