他先谢谢你的帮助。我只是在为我的学校做一件事,而我偶然发现了一个问题。这是一个简单的账单计算器,可以区分高级用户和普通用户,并根据不同的费率计算您的帐单。我以为我已经完成了它,但现在我得到这个错误。请任何帮助,只是想得到这一切说和做。C++初学者编码错误
调试错误!
程序:... \ ConsoleApplication12.exe
模块:... \ ConsoleApplication12.exe运行时检查失败#3 - T的
#include <iostream>
#include<iomanip>
using namespace std;
int main() {
const float Regular = 10;
const float Premium = 25;
const float RRate = .2;
const float DRate = .1;
const float NRate = .05;
int account;
int Rminutes;
int Dminutes;
int Nminutes;
int totalmin;
float Dcharge;
float Ncharge;
float total;
char service;
cout << "Enter the account number\n";
cin >> account;
cout << "Enter the service code\n";
cin >> service;
switch(service)
{case'r':
case'R':
cout << "Please enter the total amount of minutes used\n";
cin >> Rminutes;
if (Rminutes > 50) {
total = (Rminutes - 50)*RRate + Regular;
}
else {
total = Regular;
}
break;
case'P':
case'p':
cout << "Please enter how many minutes were used during the day\n";
cin >> Dminutes;
cout << "Please enter how many minutes were used during the night\n";
cin >> Nminutes;
if (Dminutes > 75) {
Dcharge = (Dminutes - 75)*DRate;
}
if (Nminutes > 100) {
Ncharge = (Nminutes - 100)*NRate;
}
total = Premium + Dcharge + Ncharge;
break;
default:
cout << "Invalid service code\n";
return 1;
break;
}
totalmin = Rminutes + Dminutes + Nminutes;
cout << "Your account number is:" << account;
cout << "Your type of service is:" << service;
cout << "your total minutes used was" << totalmin;
cout << "your bill is" << total;
return 0;
}
您需要将其缩小到[mcve](https://stackoverflow.com/help/mcve)。 – Jason
我只是运行Dev C++上的代码,它的工作... xD –
该代码适用于我,输出是: 您的帐号是:1您的服务类型是:使用的总分钟数是23您的帐单是10 – anthr