I am in an online introduction to programming class and my instructor isnt helping me at all with my problems! This program has a main module that utilizes submodules to complete the process. I had a pseudocode format of the correct code but my instructor didnt teach us how to change it to c++ code format. I went through all sorts of different tutorials to get some sort of grasp on it but with no reults. Please if anyone can help me with my code!
This problem has BasePrice, EngineChoice, TrimChoice, and RadioChoice as inputs and SellingPrice as the only output.
My program must 1)input the base price of car, 2)Process the various option choices to compute additional costs, 3) Total all the costs, and 4) Display the final selling price for the car and choices that you have made.
If it is at all possible try to explain what I was doing wrong or explain what new steps you added! I know this is a lot but Im desperate and my professor doesnt help at all!
// scott-assignment 3.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
float BasePrice; // the base price of vehicle
float EngineCost; // the cost of the different kinds of engines
float TrimCost; // the cost of the different kinds of trims
float RadioCost; // the cost of the different kinds of radios
int main()
{
cout << "Enter the base price of your vehicle: ";
cin >> BasePrice;
Compute_Engine_Cost();
Compute_Interior_Trim_Cost();
Compute_Radio_Cost();
Display_Selling_Price();
return 0;
}
void Compute_Engine_Cost()
{
// asking which kind of engine (submodule)
char EnginePrice;
In Compute_Engine_Cost you switch Engine cost, but it doesn't even have a value assigned to it yet. You should be switching EnginePrice instead since it is the one which can be 'S', 'E' or 'D'.
Compute_Interior_Trim_Cost is lacking a {. Also, it has the same problem as Compute_Engine_Cost.
Problem with Compute_Radio_Cost is that you have a local variable with the same name as a global variable. Also, chars R and O do NOT have values 'R' and 'O' assigned to them automatically. You don't even need them. Write if (RadioPrice == 'R') RadioCost = 100; ....
Your naming is not great. Logically variable RadioPrice should mean the same as RadioCost, but instead it doesn't. You might want to rename it to RadioType or RadioChoice, etc. for clarity.
Also, you have two int main()s. Delete the first one.