Answer to Question #288144 in C for Geetha

Question #288144

Mr. Sharma has travel plans. He wants to know the distance travelled in kilometers [KM] to



destination on October 15th. Initially Mr. Sharma travels a fixed distance of 40 KM from his



house to Airport. If October 15th is a Full working day he travels 2200 KM to attend a



Conference at Delhi, if it is a half working day he travels 350 KM to attend a Conference at



Chennai, if it is a Holiday he travels 600 KM for a Holiday in Goa.



Following are requirements to solve the problem



a. The working day status i.e., Full working day, half working day or Holiday on October 15th



has to be captured.



b. Check for the given conditions and compute the total distance



c. Display the distance travelled in KM along with the destination in an appropriate message.

1
Expert's answer
2022-01-17T08:25:07-0500
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>

/*
	Mr. Sharma has travel plans. He wants to know the distance travelled in kilometers [KM] to
	destination on October 15th. 
	Initially Mr. Sharma travels a fixed distance of 40 KM from his
	House to Airport. If October 15th is a Full working day he travels 2200 KM to attend a
	Conference at Delhi, if it is a half working day he travels 350 KM to attend a Conference at
	Chennai, if it is a Holiday he travels 600 KM for a Holiday in Goa.
	Following are requirements to solve the problem
	a. The working day status i.e., Full working day, half working day or Holiday on October 15th has to be captured.
	b. Check for the given conditions and compute the total distance
	c. Display the distance travelled in KM along with the destination in an appropriate message.
*/


#define FWD	0
#define HWD	1
#define HD	2


int main()
{
	int FD = 40;
	int WDStatus,Flag=1,d;
	
	while(Flag)
	{
		printf("\n\n\tPress 1 for Full Working Day");
		printf("\n\tPress 2 for Half Working Day");
		printf("\n\tPress 3 for Holiday");
		printf("\n\tPress 0 to QUIT");
		Flag=-1;
		while(Flag<0 || Flag>3)
		{
			printf("\n\tEnter Option (0 to 3): ");
			scanf("%d",&Flag);
		}
		if(Flag==0) exit(0);
		if(Flag==1)
		{
			printf("\n\n\tIts Full Working Day.");
			d= FD + 2200;
			printf("\n\tDistance Travelled = %d Kms. (House to Delhi)",d);
		}
		if(Flag==2)
		{
			printf("\n\n\tIts Half Working Day.");
			d= FD + 350;
			printf("\n\tDistance Travelled = %d Kms. (House to Chennai)",d);
		}
		if(Flag==3)
		{
			printf("\n\n\tIts Holiday.");
			d= FD + 600;
			printf("\n\tDistance Travelled = %d  Kms. (House to Goa)",d);
		}
	}
	return(0);	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS