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

C Programming. Use Code :: Blocks to write a program for this exercise: ( Using

ID: 3695974 • Letter: C

Question

C Programming. Use Code :: Blocks to write a program for this exercise: (Using Pointers,Arrays and Strings)

Cost Estimate:

(a) Define a pair of parallel arrays that will be used for estimating the cost of a repair job. The first array should contain the names of various parts; the second array, the price of each part.

For example, these arrays might contain data like this:

{ "muffler", "oil filter", "spark plugs", ... }

{ 39.95, 4.95, 6.00, ... }

(b) Write a program that will present a menu of parts for the user, then permit him or her to select any number of parts from the menu. After selecting a part, the program should prompt for the quantity of that part (one or more) that will be used for the repair, calculate the price for those parts, and add it to a total price. When the user selects "Done" from the menu, print the total price of all parts needed, with a sales tax of 6%.

Explanation / Answer

#include<stdio.h>
#define size 3
int main(){
char name[size][20] = { "muffler", "oil filter", "spark plugs"};
float price[size] = { 39.95, 4.95, 6.00};
int opt,i;
int quantity[size] = {0,0,0};
while(1){
printf("Select any part 1. muffle 2. oil filter 3. spark plugs 0. Done");
scanf("%d",&opt);
if(opt == 0)
break;
printf("Enter the quantity");
scanf("%d",&quantity[opt-1]);
}
float total =0,salestax;
for(i=0;i<size;i++)
total += quantity[i]*price[i];
salestax = total * .06;
float grandtotal = total + salestax;
printf(" Total = %f",total);
printf(" Sales Tax = %f",salestax);
printf(" grand total = %f",grandtotal);
}