I was tryign to write this c program, but I keep getting a bunch of errors? So i
ID: 3724671 • Letter: I
Question
I was tryign to write this c program, but I keep getting a bunch of errors? So is it possible to use if statements to work as switch statements to save on lines and correct for capitalization?
#include<stdio.h>
#include<stdlib.h>
int main ()
{
char source,destination,mode,hotel,stay,food,meals;
int cost=0;
int b,c,n,p,d,a,t,b;
int B,C,N,P,D,A,T,B;
printf("******************************************");
printf(" WELCOME TO THE TRIP EXPENSES CALCULATOR ");
printf("******************************************");
getchar();
//This screen is going to select the source city
system("cls");
printf("ENTER THE SOURCE CITY :");
printf(" B for Baltimore");
printf(" C for Chattanooga");
printf(" N for Nashville");
printf(" P for Pasadena ");
scanf(" %s",&source);
//This screen is going to select the destination city
system("cls");
printf("ENTER THE DESTINATION CITY");
printf(" D for Denver");
printf(" M for Madison");
printf(" C for Clarksville");
printf(" K for Knoxville ");
scanf(" %s",&destination);
//This screen will select the mode of travel
system("cls");
printf("ENTER THE MODE OF TRAVEL");
printf(" A for Air");
printf(" R for Train");
printf(" B for Bus ");
scanf(" %s",&mode);
//This screen is to select the hotel
system("cls");
printf("ENTER THE TYPE OF HOTEL");
printf(" F for Five Star");
printf(" T for Three star");
printf(" O for ordinary ");
scanf("%s",&hotel);
//This screen will enter the number of days in the hotel
system("cls");
printf("ENTER THE NUMBER OF DAYS OF STAY ");
scanf(" %s",&stay);
//This screen will enter the type of food you want
system("cls");
printf("ENTER THE TYPE OF FOOD");
printf(" V for Veg");
printf(" N for normal food");
printf(" C for Continental ");
scanf(" %s",&food);
//this screen asks about more stuff
system("cls");
printf("HOW MANY MEALS WOULD YOU BE EATING IN THE HOTEL? ");
scanf(" %s",&meals);
if (source=b||B,&& destination=d||D,&& mode=a||A)
{
cost = 5000;
}
else if (source=b||B,&& destination=d||D,&& mode=t||T)
{
cost = 2500;
}
else if (source=b||B,&& destination=d||D,&& mode=b||B)
{
cost = 2500;
}
}
Explanation / Answer
Use nested switch
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.