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

This assignment involves experimentation with arrays in program development and

ID: 3716037 • Letter: T

Question

This assignment involves experimentation with arrays in program development and C++.

Assignment:

1) Consider the following computer programming problem

In one of the earlier sample programs, we did a car price calculator which used if..else statements to take a number of options and compute a total price. Here we will do something in a similar vein but with arrays.

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:


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 or you will get 0 points for this assignment.
    * You MUST use a loop and search to find if the code that was input matches an option package code in the array or you will get 0 points for this assignment.
    * 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.

I just need the IPO for this problem NOT the cpp

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

Solution 1:

#include <iostream>

#include <string>

using namespace std;

int main(){

double basePrice;

string optionPackage;

string OptionPackageCodeArray[] = { "BB","SP","NP", "HE", "UC"};

double packageCostArray[] = {1500.00,3250.00,4575.00,7500.00,5220.00};

string PackageNameArray[] = {"Base","Sport","Intermediate level","Luxury","User specified"};

cout << "Input the base price of car ";

cout << "$";

cin >> basePrice;

cout << "Input the optionPackage ";

cin >> optionPackage;

int size = sizeof(OptionPackageCodeArray)/sizeof(OptionPackageCodeArray[0]);

int flag = 0;

for (int i = 0; i < size; i++)

{

if(OptionPackageCodeArray[i].compare(optionPackage) == 0){

flag = 1;

double subTotal = basePrice+packageCostArray[i];

double tax = 0.15*subTotal;

double finalPrice = subTotal+tax;

cout << "Final Price of" << PackageNameArray[i] << " is : $" << finalPrice << ".00 ";

}

}

  

if(flag==0){

cout << "Invalid option package ";

}

}

Sample Output 1:

******************************************

Input the base price of car                                                                                                    

$34000                                                                                                                         

Input the optionPackage                                                                                                        

HE                                                                                                                             

Final Price ofLuxury is : $47725.00

Sample Output 2:

******************************************

Input the base price of car                                                                                                    

$17500                                                                                                                         

Input the optionPackage                                                                                                        

KL

Invalid option package

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote