1个回答
2018-04-03
展开全部
#include <iostream>
using namespace std;
float RegularSer(int Time)
{
float result=0;
if(Time>0)
{
result=10.0;
if(Time>50)
result+= (Time-50) *0.2;
}
return result;
}
float PremiumSer(int DayTime,int NightTime)
{
float result =0;
if(DayTime>0)
{
result+=25;
if(DayTime>75)
result+=(DayTime-75)*0.1;
}
if(NightTime>0)
{
result+=25;
if(NightTime>100)
result+=(NightTime-100)*0.05;
}
return result;
}
int main()
{
string accountNum;
char Type;
cout << "Please enter your Account Number:" << endl;
cin>>accountNum;
cout <<"Please enter your Service Code(\'r\' Or \'R\' For Regular Service;\'p\' Or \'P\' For Premium Service):"<<endl;
cin>>Type;
if(Type=='r'||Type=='R')
{
int Time=0;
float amount=0;
cout<<"Please enter the number of the server was used!"<<endl;
cin>>Time;
amount=RegularSer(Time);
cout <<"Your Account Number is \""<<accountNum<<"\",You used the Regular Service "<<Time<<" minutes, amount due "<<amount<<"$."<<endl;
}
else if(Type=='p'||Type=='P')
{
int DayTime=0,NightTime=0;
float amount=0;
cout<<"Please enter the number of the server was used during the day!"<<endl;
cin>>DayTime;
cout<<"Please enter the number of the server was used during the night!"<<endl;
cin>>NightTime;
amount=PremiumSer(DayTime,NightTime);
cout <<"Your Account Number is \""<<accountNum<<"\",You used the Premium Service "<<DayTime<<" minutes during the day and "<<NightTime<<" minutes during the night , amount due "<<amount<<"$."<<endl;
}
else
{
cout<<"Sorry!Get a wrong Service Code!"<<endl;
}
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询