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

in c++, You are to write a program which inputs the base price of a car. Then, t

ID: 3761022 • Letter: I

Question

in c++,

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.
  
Notes:

    * You MUST define and use parallel arrays .
    * You MUST use a loop and search to find if the code that was input matches an option package code in the array.
    * Use doubles for ALL costs. Include dollar signs with your prompts and outputs and 2 decimal places for cents.
    * Keep the input prompts simple - do not show all the possible choices when prompting the user, for example.
        * Remember, if a wrong code is entered the program will catch and report that.
    * Do not use functions, just have one main ( ) for the whole program.
    * You will find that there are examples in your book and in this course that can be of help with this task
    * Don't forget to #include <string>
    * Test your code. As an example, if we enter 34000 as the base price, and a code of HE, we should see
            The final cost for your vehicle with Luxury trim is $47725.00
    * And, of course if we enter 17500 as the base price and a code of KL, we should see an error message


2) Write up an IPO chart for this problem. Be sure to have an "Input, Processing, Output and Algorithm" part.

3) Desk-check your solution.


   The IPO for array Project

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.
  
Notes:

    * You MUST define and use parallel arrays .
    * You MUST use a loop and search to find if the code that was input matches an option package code in the array.
    * Use doubles for ALL costs. Include dollar signs with your prompts and outputs and 2 decimal places for cents.
    * Keep the input prompts simple - do not show all the possible choices when prompting the user, for example.
        * Remember, if a wrong code is entered the program will catch and report that.
    * Do not use functions, just have one main ( ) for the whole program.
    * You will find that there are examples in your book and in this course that can be of help with this task
    * Don't forget to #include <string>
    * Test your code. As an example, if we enter 34000 as the base price, and a code of HE, we should see
            The final cost for your vehicle with Luxury trim is $47725.00
    * And, of course if we enter 17500 as the base price and a code of KL, we should see an error message


2) Write up an IPO chart for this problem. Be sure to have an "Input, Processing, Output and Algorithm" part.

3) Desk-check your solution.


this is a sample of code i have writen but am stuch because it is not reponding.please can some help me with it and if possible the IPO

#include <iostream>
using namespace std;

int main( )
{
string PackageName = "";
string OptionPackageCodeArray[5] ={ "BB", "SP", "NP", "HE","UC"};

//Prompt the user for performer name
cout << "Enter the package name (type end to quit): ";
cin >> PackageName;

double PackageCostArray[5] = { 1500, 3250, 4575, 7500, 5220 };
std::string PackageNameArray[] =
{
"Base",
"Sport",
"Intermediate Level",
"Luxury",
"User Specified"
};

system("pause");
return 0;
} //end of main

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

Explanation / Answer

finalprice.cpp

#include <iostream>//HEADER FILES
#include <string>

using namespace std;

int main( )
{
string PackageName[5] ={"Base","Sport","IntermediateLevel","Luxary","Userspecified"};
string OptionPackageCodeArray[5] ={ "BB", "SP", "NP", "HE","UC"};
string packagecode;
double PackageCostArray[5] = { 1500, 3250, 4575, 7500, 5220 };
double finalprice,baseprice;


//Prompt the user for performer name
cout << "Enter the Base Price: ";//KEYBOARD INPUTTING
cin >>baseprice;

cout << "Enter the package code: ";
cin >>packagecode;
if(packagecode!="BB" && packagecode!="SP" && packagecode!="NP" && packagecode!="HE" && packagecode!="UC"){//CHECKIG WHETHER PACKAGE CODE IS PRESENT IN ARRAY
string msg="u have entered wrong input";
cout<<msg;
}
else{
for(int i=0;i<5;i++)
{
try{//HANDLING THE EXCEPTION
if(packagecode==OptionPackageCodeArray[i])
{
finalprice=baseprice+PackageCostArray[i];//IF PACKAGE CODE IS PRESENT IN ARRAY THEN CALCULATING FINAL PRICE
finalprice=finalprice*15;
finalprice=finalprice/100;
finalprice=finalprice+baseprice+PackageCostArray[i];

}
  
}
catch(string msg)
{
  
cout<<msg;
  

}
}
  


cout<<"final price="<<finalprice;
}
return 0;
} //end of main

  
output

Enter the Base Price: 34000

Enter the package code: HE

final price=47725