| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 299 人关注过本帖
标题:大家查查我程序的错误在哪?
只看楼主 加入收藏
suckdog
Rank: 1
等 级:新手上路
帖 子:130
专家分:0
注 册:2007-9-19
结帖率:41.67%
收藏
 问题点数:0 回复次数:1 
大家查查我程序的错误在哪?
在最后要显示“yes"和"no"的时候,他要我有个"return", 我不知道要return 什么。 大家帮帮忙谢谢


/*********************************************************************************
Assignment #5 project 31 Due: 10/17/2007
Name: Quan Xu
Purpose: The program will ask users to input the number of hours they have worked, and the
rate of pay per hour, then out put the gross pay for the employee. If he/she worked
over than 80 hours per week, it will display illegal.
*********************************************************************************/
#include <iostream>
using namespace std;
int displaygrosspay (int hr, int rate);
char displayillegal (int hr);
main()
{
int hour, rate_of_pay, gross, error;
cout<<"Please enter how many hours you have worked today:\n";
cin>>hour;
cout<<endl;
cout<<"Please enter the rate of pay per hour:\n";
cin>>rate_of_pay;
cout<<endl;

gross=displaygrosspay(hour, rate_of_pay);

cout<<"You have worked "<<hour<<" hours.\n";
cout<<"And got "<<rate_of_pay<<" dollars per hour.\n";
cout<<"The gross play is "<<gross<<endl;

error=displayillegal(hour);

cout<<"Overtime?\n";
cout<<error<<endl;

return 0;
}
int displaygrosspay (int hr, int rate)
/*****************************************************************************************************
Name: displaygrosspay
Purpose : calculate the employee's gross rate
Arguments: none
Return Value: gross
*****************************************************************************************************/
{
int gross;
gross=hr*rate;
return (gross);
}

char displayillegal(int hr)
/*****************************************************************************************************
Name: displayillegal message
Purpose : tell the employees if they worked overtime
Arguments: if over 80 hrs return "yes", if less than 80 hrs, return "no"
Return Value: error
*****************************************************************************************************/
{
if (hr*5>80)
{
cout<<"Yes";
}
else
{
cout<<"No";
}
}



2007-10-16 03:12
冷云逸
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2007-10-16
收藏
得分:0 

#include <iostream>
using namespace std;
int displaygrosspay (int hr, int rate);
void displayillegal (int hr);
main()
{ int hour, rate_of_pay, gross;
cout<<"Please enter how many hours you have worked today:\n";
cin>>hour;
cout<<endl;
cout<<"Please enter the rate of pay per hour:\n";
cin>>rate_of_pay;
cout<<endl;

gross=displaygrosspay(hour, rate_of_pay);

cout<<"You have worked "<<hour<<" hours.\n";
cout<<"And got "<<rate_of_pay<<" dollars per hour.\n";
cout<<"The gross play is "<<gross<<endl;
cout<<"Overtime?\n";
displayillegal(hour);
return 0;
}
int displaygrosspay (int hr, int rate)
{
int gross;
gross=hr*rate;
return (gross);
}

void displayillegal(int hr)
{
if (hr*5>80)
{
cout<<"Yes\n";
}
else
{
cout<<"No\n";
}
}
这样可以不?


2007-10-16 12:26
快速回复:大家查查我程序的错误在哪?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026384 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved