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

Please write in C, I have finsed half of the problem finshed already. (1) Output

ID: 3788028 • Letter: P

Question

Please write in C, I have finsed half of the problem finshed already.

(1) Output a menu of automotive services and the corresponding cost of each service. (2 pts) Davy's auto shop services oil change $35 Tire rotation $19 Car Wash $7 Car wax $12 (2) Prompt the user for two services. Each service type is composed of two strings. (2 pts Select first service oil change Select secon d service Car wax (3) Output an invoice for the services selected. Output the cost for each service and the total cost. (3 pts) Davy's auto shop invoice Service 1: oil change, $35 Service 2: Car wax, $12 otal: $47 xtend the program to allow the u ser to enter a dash which indicates no service (3 pts Davy's auto shop services oil change $35 Tire rotation $19 Car Wash $7 Car wax $12 Select first service Tire rotation Select secon d service Davy's auto shop invoice Service 1: ire rotation, $19 Service 2: No service otal: $19

Explanation / Answer

#include<stdio.h>
#include<string.h>

int main(void)
{
int oilChange = 35;
int tireRotation = 19;
int carWash = 7;
int carWax = 12;

char service1[50];
char service2[50];

printf("Davy's auto shop service ");
printf("Oil change -- $%d ", oilChange);
printf("Tire rotation -- $%d ", tireRotation);
printf("Car wash -- $%d ", carWash);
printf("Car wax -- $%d ", carWax);

printf("Select first service: ");
fgets(service1, sizeof(service1), stdin);
strtok(service1, " ");

printf("Select second service: ");
fgets(service2, sizeof(service2), stdin);
strtok(service2, " ");

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

int total = 0;
int price1 = 0;
int price2 = 0;

if (strcmp(service1, "-") == 0)
{
strcpy(service1, "No service");
price1 = 0;
}

if (strcmp(service2, "-") == 0)
{
strcpy(service2, "No service");
price2 = 0;
}

if (strcmp(service1, "Oil change") == 0)
{
price1 = oilChange;
}
if (strcmp(service2, "Oil change") == 0)
{
price2 = oilChange;
}

if (strcmp(service1, "Tire rotation") == 0)
{
price1 = tireRotation;
}
if (strcmp(service2, "Tire rotation") == 0)
{
price2 = tireRotation;
}

if (strcmp(service1, "Car wash") == 0)
{
price1 = carWash;
}
if (strcmp(service2, "car wash") == 0)
{
price2 = carWash;
}

if (strcmp(service1, "Car wax") == 0)
{
price1 = carWax;
}
if (strcmp(service2, "Car wax") == 0)
{
price2 = carWax;
}

total = price1 + price2;

printf("Service 1: %s", service1);
if (price1 != 0)
{
printf(", $%d", price1);
}
printf(" ");
printf("Service 2: %s", service2);
if (price2 != 0)
{
printf(", $%d", price2);
}
printf(" ");
printf("Total: $%d ", total);
}