用s witch语句实现复印店的详细VC6.0编程代码。复印价格表如下:A4纸复印单价格不超过20张为0.5元,超过20张到50张到部分为0.4元,超过50张到100张的部分为0.3元,超过100张的部分为0.2元。A3纸复印单价格不超过20张为0.8元,超过20张到50张到部分为0.7元,超过50张到100张的部分为0.6元,超过100张的部分为0.5元
时间: 2024-02-19 13:57:21 浏览: 139
好的,以下是VC6.0的代码实现:
```cpp
#include <iostream>
using namespace std;
int main()
{
char size; // 纸张大小
int num; // 复印张数
double price; // 复印价格
cout << "请输入纸张大小(A3或A4)和复印张数:" << endl;
cin >> size >> num;
switch (size)
{
case 'A4':
if (num <= 20)
{
price = num * 0.5;
}
else if (num <= 50)
{
price = 20 * 0.5 + (num - 20) * 0.4;
}
else if (num <= 100)
{
price = 20 * 0.5 + 30 * 0.4 + (num - 50) * 0.3;
}
else
{
price = 20 * 0.5 + 30 * 0.4 + 50 * 0.3 + (num - 100) * 0.2;
}
break;
case 'A3':
if (num <= 20)
{
price = num * 0.8;
}
else if (num <= 50)
{
price = 20 * 0.8 + (num - 20) * 0.7;
}
else if (num <= 100)
{
price = 20 * 0.8 + 30 * 0.7 + (num - 50) * 0.6;
}
else
{
price = 20 * 0.8 + 30 * 0.7 + 50 * 0.6 + (num - 100) * 0.5;
}
break;
default:
cout << "输入有误,请重新输入!" << endl;
return 0;
}
cout << "复印" << num << "张" << size << "纸的价格为:" << price << "元" << endl;
return 0;
}
```
阅读全文