#include<iostream>
#include<iomanip>
using namespace std;
double calculatecharges(double);
int main()
{
double hours,totalhours=0.0,totalcharges=0,ncar;
cin>>hours;
cout<<left<<setw(6)<<"Car"<<right<<setw(6)<<"Hours"<<right<<setw(6)<<"Charge";
for(ncar=1;ncar<=3;ncar++)
{
totalhours+=hours;
double m=calculatecharges(hours);
totalcharges+=m;
cout<<right<<setw(6)<<ncar<<right<<setw(6)<<hours<<right<<setw(6)<<m;
cin>>hours;
}
cout<<right<<setw(6)<<"TOTAL"<<right<<setw(6)<<totalhours<<right<<setw(6)<<totalcharges;
system("pause");
return 0;
}
double calculatecharges(double h)
{
if(h<=3) return(2.00);
if(h>3&&2+0.5(h-3)<=10) return(0.50(h-3)+2.00);
if(h>3&&2+0.5(h-3)>10) return(10.00);
}
说是
if(h>3&&2+0.5(h-3)<=10) return(0.50(h-3)+2.00);
if(h>3&&2+0.5(h-3)>10) return(10.00);
error C2064: 项不会计算为接受 1 个参数的函数
蟹蟹大家
#include<iomanip>
using namespace std;
double calculatecharges(double);
int main()
{
double hours,totalhours=0.0,totalcharges=0,ncar;
cin>>hours;
cout<<left<<setw(6)<<"Car"<<right<<setw(6)<<"Hours"<<right<<setw(6)<<"Charge";
for(ncar=1;ncar<=3;ncar++)
{
totalhours+=hours;
double m=calculatecharges(hours);
totalcharges+=m;
cout<<right<<setw(6)<<ncar<<right<<setw(6)<<hours<<right<<setw(6)<<m;
cin>>hours;
}
cout<<right<<setw(6)<<"TOTAL"<<right<<setw(6)<<totalhours<<right<<setw(6)<<totalcharges;
system("pause");
return 0;
}
double calculatecharges(double h)
{
if(h<=3) return(2.00);
if(h>3&&2+0.5(h-3)<=10) return(0.50(h-3)+2.00);
if(h>3&&2+0.5(h-3)>10) return(10.00);
}
说是
if(h>3&&2+0.5(h-3)<=10) return(0.50(h-3)+2.00);
if(h>3&&2+0.5(h-3)>10) return(10.00);
error C2064: 项不会计算为接受 1 个参数的函数
蟹蟹大家