Answer to Question #208372 in C for R SWASTHIK

Question #208372


Mr. Sharma has travel plans. He wants to know the distance ravelled 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 al

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

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 caplured.

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
2021-06-18T05:49:32-0400
#include <stdio.h>

int main() {
    int input;

    printf("Mr. Sharma has travel plans.\nHe wants to know the distance travelled in kilometers [KM] to destination on October 15th.\nPlease indicate the condition for further calculations.\n\n");

    printf("Please indicate if October 15th is the:\n1. Full working day\n2. Half working day\n3. Holiday\n\nEnter a single number relevant to your choice:\n");

    scanf("%d", &input);

    if ( input < 1 || input > 3 ) {
        printf("Error: You need to choose one option: 1, 2 or 3\n");
        return 0;
    }

    if ( input == 1 ) {
        printf("\nMr. Sharma travels a distance of 40 KM from his house to Airport.\nAlso he travels 2200 KM to attend a Conference at Delhi.\nTotal distance is 2240 KM.\n");
    } else if ( input == 2 ) {
        printf("\nMr. Sharma travels a distance of 40 KM from his house to Airport.\nAlso he travels 350 KM to attend a Conference at Chennai.\nTotal distance is 390 KM.\n");
    } else {
        printf("\nMr. Sharma travels a distance of 40 KM from his house to Airport.\nAlso he travels 600 KM for a Holiday in Goa.\nTotal distance is 640 KM.\n");
    }

    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