- 分享
- 0
- 人气
- 0
- 主题
- 2
- 帖子
- 25
- UID
- 163638
- 积分
- 66
- 阅读权限
- 12
- 注册时间
- 2008-8-31
- 最后登录
- 2018-7-20
- 在线时间
- 231 小时
 
|
本帖最后由 karkit1990 于 2013-12-1 12:39 AM 编辑
我写了一个,不过我没有test过的,你试一下看能用吗
#include<iostream>
using namespace std;
int main()
{
int startTime,endTime,weekday,weekend,hrs,min,minutes;
double cost;
char first, second, choice;
do
{
do
{
cout<<"When did the call start?\n";
cout<<"Please enter the time in 24-hour notation.\n";
cin>>startTime;
cout<<"How long did the call last?\n";
cin>>minutes;
cout<<"Please enter the first two letters of the day of the call.\n";
cin>>first>>second;
} while ((((first!='M')||(first!='m'))&&((second!='O')||(second!='o'))) || (((first!='T')||(first!='t'))&&((second!='U')||(second!='u'))) || (((first!='W')||(first!='w'))&&((second!='E')||(second!='e'))) || (((first!='T')||(first!='t'))&&((second!='H')||(second!='h'))) || (((first!='F')||(first!='f'))&&((second!='R')||(second!='r'))) || (((first!='S')||(first!='s'))&&((second!='A')||(second!='a'))) || (((first!='S')||(first!='s'))&&((second!='U')||(second!='u'))));
if ((first=='M')||(first=='m')||(first=='T')||(first=='t')||(first=='W')||(first=='w')||(first=='T')||(first=='t')||(first=='F')||(first=='f'))
{
if ((startTime>=800)&&(startTime<=1800))
cost=minutes*.40;
else
cost=minutes*.25;
}
else
cost=minutes*0.15;
if ((first=='F')||(first=='f'))
{
hrs = minutes / 60 * 100;
min = minutes % 60;
endTime = starTime + hrs + min;
if (endTime > 2400)
{
weekday = ((2400 - startTime) / 100 * 60 ) * .25;
weekend = ((endTime - startTime) / 100 * 60)*.15;
cost = weekday + weekend;
}
}
if ((first=='S')||(first=='s')) && ((second=='U')||(second=='u'))
{
hrs = minutes / 60 * 100;
min = minutes % 60;
endTime = starTime + hrs + min;
if (endTime > 2400)
{
weekday = ((endTime - startTime) / 100 * 60 ) * .25;
weekend = ((2400 - startTime) / 100 * 60)*.15;
cost = weekday + weekend;
}
}
cout<<"The cost of the call is "<<cost<<".\n";
cout<<endl;
cout<<"Do you want to rerun the program? Y or N\n";
cin>>choice;
cout<<endl;
}while ((choice=='Y')||(choice=='y'));
return 0;
} |
|