C Programming Lanuage(C++) Write a program for Cody’s Car Care Shop that shows a
ID: 3797856 • Letter: C
Question
C Programming Lanuage(C++)
Write a program for Cody’s Car Care Shop that shows a user a list of available services:
1. oil change $25.00
2. tire rotation $22.00
3. battery check $15.00
4. brake inspection $ 5.00
5. calculate total Allow the user to select several choices, and when they select 5, calculate the final total (plus 6% tax).
Create an array that holds the prices. As the user selects an option, display the option number and its price as $25, $22, $15, or $5, accordingly. Display an error message if the user enters an invalid item. When the user selects 5, display the net total, the amount of tax, and the grand total.
#include <stdio.h>-PLEASE
Explanation / Answer
# include<stdio.h>
// Program for Cody's Car Care Shop
// Performs operations depending the input from user
int main()
{
int arr[] = {0,0,0,0};
printf( "1. oil change " );
printf( "2. tire rotation " );
printf( "3. battery check " );
printf( "4. brake inspection " );
printf( "5. calculate total " );
int input;
scanf("%d",&input);
do{
if(input == 1){
printf( "1. oil change: $25.00 " );
arr[0]+=1;
}
else if(input == 2){
printf( "2. tire rotation: $22.00 " );
arr[1]+=1;
}
else if(input == 3){
printf( "3. battery check: $15.00 " );
arr[2]+=1;
}
else if(input == 4){
printf( "4. brake inspection $ 5.00 " );
arr[3]+=1;
}
else if(input == 5){
break;
}
else{
printf( "Bad input, re-enter the input. " );
}
scanf("%d", &input);
}while(input!=5);
float net_total = 25*arr[0] + 22*arr[1] + 15*arr[2] + 5*arr[3];
float tax = net_total*.06;
float grand_total= net_total + tax;
printf( "Net total is %.2f, tax is %.2f and grand total is %.2f ",net_total,tax,grand_total );
getchar();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.