测试题:
某跨国产品公司目前已经开设了中国、美国、日本、韩国4个子公司,并且未来有在更多国家开设子公司的计划。
该公司在各个子公司的会员等级体系不同,但产品模型数据是完全一致的,产品平时在各个分公司分别有不同的销售价格。
该公司现计划在全公司范围内进行618促销,针对不同用户的会员等级,对产品销售实行不同折扣优惠,各公司会员等级等详细信息如下表:
子公司 | 语言 | 会员等级体系 | 货币单位 |
中国公司 | 汉语 | 超级VIP用户:7折优惠 VIP用户:9折优惠 普通用户:无优惠 | 人民币 |
美国公司 | 英语 | 金牌客户:6.5折优惠 银牌客户:7.5折优惠 铜牌客户:8.5折优惠 普通用户:无优惠 | 美元 |
韩国公司 | 韩语 | 皇冠会员:8折优惠 普通用户:无优惠 | 韩元 |
日本公司 | 日语 | A级客户:6.5折优惠 B级客户:7.5折优惠 C级客户:8.5折优惠 普通用户:无优惠 | 日元 |
请设计一款618促销商品报价查询系统,满足下列功能要求:
- 软件同时支持为多个子公司客户报价;
- 系统提示用户输入其所在的区域、会员等级后,按照相应的语言、货币单位、折扣体系显示产品报价;
- 软件支持5种以上的产品报价;
- 软件设计应充分考虑未来在更多国家开设子公司的可能。
代码实现:
#include<bits/stdc++.h>
using namespace std;
const double CN_SVip = 0.7;
const double CN_Vip = 0.9;
const double CN_Normal = 1;
const double USA_gold = 0.65;
const double USA_silver = 0.75;
const double USA_copper = 0.85;
const double USA_Normal = 1;
const double Korea_crown = 0.8;
const double Korea_Normal = 1;
const double Japan_A = 0.65;
const double Japan_B = 0.75;
const double Japan_C = 0.85;
const double Japan_Normal = 1;
class user {
public:
user(string uType,double price) {
userType = uType;
curPrice = price;
newPrice = price;
}
double getCNprice() {
curPrice = curPrice * 6.75;
if (userType == "CN_SVip") newPrice = curPrice * CN_SVip;
else if (userType == "CN_Vip") newPrice = curPrice * CN_Vip;
else if (userType == "CN_Normal") newPrice = curPrice* CN_Normal;
else
{
cout << "The user type you entered is wrong, please re-enter." << endl;
newPrice = -1;
}
return newPrice;
}
double getUSAprice() {
if (userType == "USA_gold") newPrice = curPrice * USA_gold;
else if (userType == "USA_silver") newPrice = curPrice * USA_silver;
else if (userType == "USA_copper") newPrice = curPrice * USA_copper;
else if (userType == "USA_Normal") newPrice = curPrice* USA_Normal;
else
{
cout << "The user type you entered is wrong, please re-enter." << endl;
newPrice = -1;
}
return newPrice;
}
double getKoreaprice() {
curPrice = curPrice * 1317.92;
if (userType == "Korea_crown") newPrice = curPrice * Korea_crown;
else if (userType == "Korea_Normal") newPrice = curPrice* Korea_Normal;
else
{
cout << "The user type you entered is wrong, please re-enter." << endl;
newPrice = -1;
}
return newPrice;
}
double getJapanprice() {
curPrice = curPrice * 138.94;
if (userType == "Japan_A") newPrice = curPrice * Japan_A;
else if (userType == "Japan_B") newPrice = curPrice * Japan_B;
else if (userType == "Japan_C") newPrice = curPrice * Japan_C;
else if (userType == "Japan_Normal") newPrice = curPrice* Japan_Normal;
else
{
cout << "The user type you entered is wrong, please re-enter." << endl;
newPrice = -1;
}
return newPrice;
}
double getNewPrice() {
return this->newPrice;
}
private:
string userType;
double newPrice;
double curPrice;
};
int main()
{
cout << "Welcome to the quotation inquiry system!" << endl;
//cout << "Please enter your region and membership level:" << endl;
//cout << "You can choose from the following options to enter" << endl;
cout << "If you are a Chinese user, You can choose the following options to enter: CN_SVip、CN_Vip、CN_Normal" << endl;
cout << "If you are an American user, You can choose the following options to enter: USA_gold、USA_silver、USA_copper、USA_Normal" << endl;
cout << "If you are a Korean user, You can choose the following options to enter: Korea_crown、Korea_Normal" << endl;
cout << "If you are a Japanese user, You can choose the following options to enter: Japan_A、Japan_B、Japan_C、Japan_Normal" << endl;
string uType = "";
double price;
while(1)
{ if(uType == "")
{
cout << "Please enter your region and membership level:(If you want to exit this program, please enter: exit)" << endl;
cin >> uType;
}
if (uType[0] == 'C')
{
cout << "请输入商品价格(美元 $):(如果想要退出程序,请输入:-1)" << endl;
cin >> price;
if(price == -1)
{
break;
}
else if(price < 0)
{
cout << "您输入的价格有误,请重新输入。" << endl;
continue;
}
user User(uType, price);
User.getCNprice();
if(User.getNewPrice() == -1)
{
uType = "";
}
else
cout << "根据您的会员等级,您需要支付:"<< User.getNewPrice() << " 人民币。"<< endl;
}
else if (uType[0] == 'U')
{
cout << "Please enter the commodity price(Dollar $):(If you want to exit this program, please enter: -1)" << endl;
cin >> price;
if(price == -1)
{
break;
}
else if(price < 0)
{
cout << "The price you entered is incorrect. Please re-enter it." << endl;
continue;
}
user User(uType, price);
User.getUSAprice();
if(User.getNewPrice() == -1)
{
uType = "";
}
else
cout << "According to your membership level, you need to pay:"<< User.getNewPrice() << " dollar." << endl;
}
else if (uType[0] == 'K') //韩文输出乱码,用英文代替
{
cout << "Please enter the commodity price(Dollar $):(If you want to exit this program, please enter: -1)" << endl;
cin >> price;
if(price == -1)
{
break;
}
else if(price < 0)
{
cout << "The price you entered is incorrect. Please re-enter it." << endl;
continue;
}
user User(uType, price);
User.getKoreaprice();
if(User.getNewPrice() == -1)
{
uType = "";
}
else
cout << "According to your membership level, you need to pay:"<< User.getNewPrice() << " Korean won." << endl;
//cout << "회원 수준에 따라 지불해야합니다:"<< User.getNewPrice() << endl;
}
else if (uType[0] == 'J')
{
cout << "製品価格(ドル $)を入力してください:(このプログラムを終了する場合は、入力してください:-1)" << endl;
cin >> price;
if(price == -1)
{
break;
}
else if(price < 0)
{
cout << "入力価格が間違っています。" << endl;
continue;
}
user User(uType, price);
User.getJapanprice();
if(User.getNewPrice() == -1)
{
uType = "";
}
else
cout << "メンバーシップレベルに応じて、あなたは支払う必要があります:"<< User.getNewPrice() << " 日本円。" << endl;
}
else if(uType == "exit")
{
break;
}
else
{
cout << "The region you entered is wrong. Please re-enter it." << endl;
uType = "";
}
}
return 0;
}