Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

can someone help me solve the following C program. Not C++. C. Automobile servic

ID: 3882758 • Letter: C

Question

can someone help me solve the following C program. Not C++. C.

Automobile service invoice (C)

(1) Output a menu of automotive services and the corresponding cost of each service. (2 pts)

Ex:


(2) Prompt the user for two services. Each service type is composed of two strings. (2 pts)

Ex:


(3) Output an invoice for the services selected. Output the cost for each service and the total cost. (3 pts)


(4) Extend the program to allow the user to enter a dash (-), which indicates no service. (3 pts)

Ex:

heres the started teplate code i was given

#include <stdio.h>
// FIXME include the string library

int main(void) {

/* Type your code here. */

return 0;
}

Explanation / Answer

#include <stdio.h>

#include <string.h>

int main(void)

{

char firstService[20],secondService[20];

int cost1,cost2,total;

total = 0;

printf("Davy's auto shop services");

printf(" Oil change -- $35");

printf(" Tire rotation -- $19");

printf(" Car wash -- $7");

printf(" Car wax -- $12");

//input 2 services

printf(" Select first service");

gets(firstService);

printf(" Select second service");

gets(secondService);

printf(" Davy's autoshop invoice");

//calculate cost of serices

if(strcmp(firstService,"Oil change")== 0)

{

cost1 = 35;

}

else if(strcmp(firstService,"Tire rotation")== 0)

{

cost1 = 19;

}

else if(strcmp(firstService,"Car wash")== 0)

{

cost1 = 7;

  

}

else if(strcmp(firstService,"Car wax")== 0)

{

cost1 = 12;

  

}

else if(strcmp(firstService,"-")== 0)

{

cost1 = 0;

  

}

if(strcmp(secondService,"Oil change")== 0)

{

cost2 = 35;

}

else if(strcmp(secondService,"Tire rotation")== 0)

{

cost2 = 19;

}

else if(strcmp(secondService,"Car wash")== 0)

{

cost2 = 7;

  

}

else if(strcmp(secondService,"Car wax")== 0)

{

cost2 = 12;

  

}

else if(strcmp(secondService,"-")== 0)

{

cost2 = 0;

  

}

//display services and cost

printf(" Service 1 : %s , $%d",firstService,cost1);

printf(" Service 2 : %s , $%d",secondService,cost2);

printf(" Total : %d",cost1+cost2);

return 0;

}

Output:

Davy's auto shop services
Oil change -- $35
Tire rotation -- $19
Car wash -- $7
Car wax -- $12
Select first service Tire rotation
Select second service -
Davy's autoshop invoice
Service 1 : Tire rotation , $19
Service 2 : - , $0

Total : 19

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote