-3
我目前正在做一项任务,它的目的是采取一个车身商店提供不同价格的不同修剪包的概念,该程序旨在使用预测试循环来停止功能如果用户输入一个不在阵列上的代码,然后用户输入其汽车的基本价格,并且该程序旨在添加基本价格,修剪价格和15%的销售税,并给出新的用户的总成本。如果我只需要创建一个显示数组的,我认为我没有问题的功能,但我目前正在撕裂我的头发了试图总结我的周围如何得到头的所有不同的功能一起工作平行阵列在循环功能
currently my algorithm is
1)enter the base price of car
2.) Enter the trim package code
3.) searchIndex=0
while OptionPackageCodeArray =[search index]
searchIndex++
end loop
if searchIndex<5
input packageCode
OptionPackageCode[searchIndex] = packageCode
else
Display error "This code does not exist"
end if
4.) Determine totalCost
PackageCostArray[searchIndex] + basePrice = costwithPackage
totalCost = costwithPackage*0.15
5.) display total cost
"The price of your car with Trim is" : totalCost
end loop
与实际C++我写到目前为止
#include <iostream>
#include <string>
using namespace std;
int main()
{
//declare variables
double basePrice = 0.00;
string OptionPackageCodeArray[] = {"BB", "SP", "NP", "HE", "UC"};
double PackageCostArray [] = {1500.00, 3250.00, 4575.00, 7500.00, 5220.00};
double totalCost = 0.00
//prompt for base price
cout << "Enter base price:";
cin>>basePrice;
cout <<"enter package code: BB, SP, NP, HE, UC";
cin >> OptionPackageCodeArray;
}
但我被困在这一点上 如果任何人有任何建议,我很乐意带他们。
“我卡住”涵盖了很多地面。你可以说得更详细点吗?你不知道该怎么做? –
主要是关于如何让循环解析出不在数组中的字母代码,并在给出不正确的代码时传递错误消息 – gordiehow