Write up an IPO chart for this problem. Be sure to have an \"Input, Processing,
ID: 673137 • Letter: W
Question
Write up an IPO chart for this problem. Be sure to have an "Input, Processing, Output and Algorithm" part. You are to write a program which inputs the base price of a car. Then, the program will input in a 2-letter code (a string) which corresponds to an option package. All the 2 letter codes will be in an array (string), along with the corresponding cost of the package in a parallel array (doubles), and there is also another array with the name of the package (string). Here is the data for the 3 parallel arrays: OptionPackageCodeArray PackageCostArray PackageNameArray BB 1500.00 Base SP 3250.00 Sport NP 4575.00 Intermediate level HE 7500.00 Luxury UC 5220.00 User specified Your program first has to determine if the 2-letter code input by the user is valid. You are required to use a loop to check the input against each item in the optionPackageCodeArray. Begin with the first item then "walk" down through the array. If the code does NOT exist on the list, display an error message and stop. If the code is valid, do some calculation and displaying. First, add the base price to the package cost from the array and get a subtotal. Then, calculate 15% of the subtotal for taxes and fees and add that to the subtotal for a final price. Display the final price and the full name of the package from the last array, then stop.
Explanation / Answer
code, cost, array
BB 1500.00 Base
SP 3250.00 Sport
NP 4575.00 Intermediate level
HE 7500.00 Luxury
UC 5220.00 User specified
int main()
{
int baseprice;
char pkgName[2];
char pkgNameArray={"Base","Sport","Intermediate level","Luxury","User Specified"};
char pkgCodeArray={"BB","SP","NP","HE","UC"};
double pkgCostArray={1500.00,3250.00,4575.00,7500.00,5220.00};
printf("Enter base price of car");
scanf("%d",&baseprice);
printf("Enter Package Name of car");
scanf("%s",pkgName);
for(int i=0;i<sizeof(pkgCodeArray); i++)
{
if(strcmp(pkgName,pkgCodeArray[i])==0)
{
double subtotal=baseprice+pkgCostArray[i];
double tax=0.15*subtotal;
double total=subtotal+tax;
printf("final cose is %d",total);
printf("Full Package NAme is %s",pkgNameArray[i]);
}
else printf("Error message, Invalid COde");
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.