
October 24th, 2012, 07:49 PM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 2
Time spent in forums: 30 m 58 sec
Reputation Power: 0
|
|
|
Newby needs help with simple program
Trying to write a program where it calculates the cost of a car with a selected option package. 4 hours into it and I am about to go insane. Here's that assignment:
Input a base price
Input an option package code (2 letter code)
Subtotal
Apply 15% tax
Attach package code to a package name
Display package name and total price
use loops, parallel arrays
No functions
Is anyone interested in helping me? Below is my code so far, which doesn't get me far.
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
//Declare arrays and variables
char optionPackageCodeArray [5] = {'BB','SP','NP','HE','UC'};
double packageCostArray [5] = {1500,3250,4575,7500,5220};
string packageNameArray [5] = {'Base','Sport','Intermediate level','Luxury','User Specified'};
double basePrice = 0.0;
double packageCost = 0.0;
double subTotal = 0.0;
double taxCost = 0.0;
double totalCost = 0.0;
char packageName = ' ';
char optionPackageCode = ' ';
char searchIndex = ' ';
int sub = 0;
//Prompt user for base price and option code
cout<<"Enter the Base Price: $";
cin>> basePrice;
cout<<"Enter the Option Code:";
cin>>optionPackageCode;
//Find the optionPackageCode
while (sub < 5 && optionPackageCodeArray[sub] != optionPackageCode)
sub +=1;
//end while
//Associate the optionPackageCode with the packageCost
if (sub < 5)
cout << "Option Cost is: $" <<packageCost[sub]<<endl;
else
cout << "Invalid Code" <<endl;
//end if
subTotal = basePrice + packageCost;
totalCost = subTotal * 1.15;
//Display total cost of car with options and tax
cout<<endl;
for(char displayIndex = 0; displayIndex <5; displayIndex++)
cout<<"Your final cost with the "<<packageName<<" is: $"<<totalCost<<endl;
system("pause");
return 0;
} //end of main
|