Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Heres what i have so far. #include #include int main () { // Declaration char sourceCity; char destCity; char modeTravel; char hoteltype; char mealType; int

image text in transcribedimage text in transcribedimage text in transcribed

Heres what i have so far.

#include

#include

int main () { // Declaration char sourceCity; char destCity; char modeTravel; char hoteltype; char mealType; int numStay=0; int numMeal=0; int transportationCost=0; int hotelCost=0; int mealCost=0; int totalCost=0;

printf(" "); printf(" "); printf("********************************************"); printf(" "); printf(" "); printf(" "); printf(" "); printf("WELCOME TO THE TRIP EXPENSES CALCULATOR"); printf(" "); printf(" "); printf(" "); printf(" "); printf("********************************************");

getchar(); system("cls");

printf(" ENTER THE SOURCE CITY: "); printf(" "); printf("B for Baltimore "); printf(" "); printf("C for Chattanooga "); printf(" "); printf("N for Nashville "); printf(" "); printf("P for Pasadena ");

scanf("%c", &sourceCity);

system("cls"); getchar();

printf(" ENTER THE DESTINATION CITY: "); printf(" "); printf("D for Denver "); printf(" "); printf("M for Madison "); printf(" "); printf("C for Clarksville "); printf(" "); printf("K for Knoxville ");

scanf("%c", &destCity);

system("cls"); getchar();

printf(" ENTER THE MODE OF TRAVEL: "); printf(" "); printf("A for Air "); printf(" "); printf("R for Train "); printf(" "); printf("B for Bus ");

scanf("%c", &modeTravel);

system("cls");

char city[12]="";

switch(sourceCity) { case 'b': case 'B': strcpy(city, "Baltimore");

// Transportation Charges if (destCity == 'd' || destCity == 'D') { if (modeTravel == 'a' || modeTravel == 'A') transportationCost=5000; else if (modeTravel == 't' || modeTravel == 'T') transportationCost=2500; else if (modeTravel == 'b' || modeTravel == 'B') transportationCost = 2000; } else if (destCity == 'm' || destCity == 'M') { if (modeTravel == 'a' || modeTravel == 'A') transportationCost = 4000; else if (modeTravel == 't' || modeTravel == 'T') transportationCost = 2000; else if (modeTravel == 'b' || modeTravel == 'B') transportationCost = 1000; } else if (destCity == 'k' || destCity == 'K') { if (modeTravel == 'a' || modeTravel == 'A') transportationCost = 5000; else if (modeTravel == 't' || modeTravel == 'T') transportationCost = 2500; else if (modeTravel == 'b' || modeTravel == 'B') transportationCost = 2000; } else if (destCity == 'c' || destCity == 'C') { if (modeTravel == 'a' || modeTravel == 'A') transportationCost = 2500; else if (modeTravel == 't' || modeTravel == 'T') transportationCost = 800; else if (modeTravel == 'b' || modeTravel == 'B') transportationCost = 1000; } }

switch(sourceCity) { case 'c': case 'C': strcpy(city, "Chattanooga");

if (destCity == 'd' || destCity == 'D') { if (modeTravel == 'a' || modeTravel == 'A') transportationCost=2500; else if (modeTravel == 't' || modeTravel == 'T') transportationCost=500; else if (modeTravel == 'b' || modeTravel == 'B') transportationCost = 600; } else if (destCity == 'm' || destCity == 'M') { if (modeTravel == 'a' || modeTravel == 'A') transportationCost = 4000; else if (modeTravel == 't' || modeTravel == 'T') transportationCost = 2300; else if (modeTravel == 'b' || modeTravel == 'B') transportationCost = 1300; } else if (destCity == 'k' || destCity == 'K') { if (modeTravel == 'a' || modeTravel == 'A') transportationCost = 4000; else if (modeTravel == 't' || modeTravel == 'T') transportationCost = 1600; else if (modeTravel == 'b' || modeTravel == 'B') transportationCost = 1400; } else if (destCity == 'c' || destCity == 'C') { if (modeTravel == 'a' || modeTravel == 'A') transportationCost = 6000; else if (modeTravel == 't' || modeTravel == 'T') transportationCost = 2000; else if (modeTravel == 'b' || modeTravel == 'B') transportationCost = 1700; } }

switch(sourceCity) { case 'n': case 'N': strcpy(city, "Nashville");

// Transportation Charges if (destCity == 'd' || destCity == 'D') { if (modeTravel == 'a' || modeTravel == 'A') transportationCost=5000; else if (modeTravel == 't' || modeTravel == 'T') transportationCost=1500; else if (modeTravel == 'b' || modeTravel == 'B') transportationCost = 1400; } else if (destCity == 'm' || destCity == 'M') { if (modeTravel == 'a' || modeTravel == 'A') transportationCost = 2500; else if (modeTravel == 't' || modeTravel == 'T') transportationCost = 900; else if (modeTravel == 'b' || modeTravel == 'B') transportationCost = 700; } else if (destCity == 'k' || destCity == 'K') { if (modeTravel == 'a' || modeTravel == 'A') transportationCost = 4000; else if (modeTravel == 't' || modeTravel == 'T') transportationCost = 1500; else if (modeTravel == 'b' || modeTravel == 'B') transportationCost = 1000; } else if (destCity == 'c' || destCity == 'C') { if (modeTravel == 'a' || modeTravel == 'A') transportationCost = 4500; else if (modeTravel == 't' || modeTravel == 'T') transportationCost = 1700; else if (modeTravel == 'b' || modeTravel == 'B') transportationCost = 1300; } }

switch(sourceCity) { case 'p': case 'P': strcpy(city, "Pasadena");

// Transportation Charges if (destCity == 'd' || destCity == 'D') { if (modeTravel == 'a' || modeTravel == 'A') transportationCost=5000; else if (modeTravel == 't' || modeTravel == 'T') transportationCost=2000; else if (modeTravel == 'b' || modeTravel == 'B') transportationCost = 1400; } else if (destCity == 'm' || destCity == 'M') { if (modeTravel == 'a' || modeTravel == 'A') transportationCost = 4500; else if (modeTravel == 't' || modeTravel == 'T') transportationCost = 1900; else if (modeTravel == 'b' || modeTravel == 'B') transportationCost = 1300; } else if (destCity == 'k' || destCity == 'K') { if (modeTravel == 'a' || modeTravel == 'A') transportationCost = 3000; else if (modeTravel == 't' || modeTravel == 'T') transportationCost = 1200; else if (modeTravel == 'b' || modeTravel == 'B') transportationCost = 800; } else if (destCity == 'c' || destCity == 'C') { if (modeTravel == 'a' || modeTravel == 'A') transportationCost = 4500; else if (modeTravel == 't' || modeTravel == 'T') transportationCost = 1700; else if (modeTravel == 'b' || modeTravel == 'B') transportationCost = 1300; } }

printf(" ENTER THE TYPE OF HOTEL: "); printf(" "); printf("F for Five Star "); printf(" "); printf("T for Three Star "); printf(" "); printf("O for Ordinary ");

scanf("%c", &hotel);

getchar(); system("cls");

// Hotel Charges switch(hotel) { if (hotel == 'f' || hotel == 'H') hotelCost=500; else if (hotel == 't' || hotel == 'T') hotelCost=300; else if (hotel == 'o' || hotel == 'O') hotelCost=100; }

printf(" ENTER THE NUMBER OF DAYS OF STAY: "); printf(" ");

scanf("%d", &numStay);

getchar(); system("cls");

printf(" ENTER THE TYPE OF FOOD: "); printf(" "); printf("V for Veg "); printf(" "); printf("N for Non-Veg "); printf(" "); printf("C for Continental ");

scanf("%c", &mealType);

getchar(); system("cls");

// Meal Charges switch(mealType) { if (mealType == 'v' || mealType == 'V') mealCost=15; else if (mealType == 'n' || mealType == 'N') mealCost=30; else if (mealType == 'c' || mealType == 'C') mealCost=15; }

printf(" How many meals would you like eat in the Hotel? "); printf(" ");

scanf("%d", &numMeal);

getchar(); system("cls");

// Total Charges hotelCharge = hotelCost * numStay; mealCharge = mealCost * numMeal * numStay; totalCost = transportationCost + (hotelCost * numStay) + (mealCost * numMeal * numStay);

// Output printf(" ********************************************************** "); printf(" TOTAL EXPENSES TO TRAVEL from %c is: ", city); printf(" **********************************************************"); printf(" "); printf(" TRANSPORTATION CHARGES = %d ", transportationCost); printf(" "); printf("NUMBER OF DAYS OF STAY = %d ", numStay); printf(" "); printf("NUMBER OF MEALS IN A DAY = %d ", numMeal); printf(" "); printf("ROOM CHARGES = %d ", hotelCharge); printf(" "); printf("FOOD CHARGES = %d ", mealCharge); printf(" "); printf("HOTEL CHARGE = %d ", hotelCharge); printf(" "); printf(" "); printf("********************************************************** "); printf(" "); printf("TOTAL CHARGES = %d ", totalCost); printf(" "); printf(" "); printf("********************************************************** ");

return 0; }

Here is my output

sourcecity: Baltimore

destination city: Denver

mode of transportation: Air

hotel choice: five stars

choice of meal: continental

image text in transcribed

I cant get the strcpy to work for "Total expenses to travel from _______ is: "

also the room charges, food charges, and hotel charges to work.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions