| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1124 人关注过本帖
标题:求编个程序 谢谢
取消只看楼主 加入收藏
lovekinglet
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2008-10-17
收藏
 问题点数:0 回复次数:3 
求编个程序 谢谢
我是个新手,刚学 .希望大家帮帮我.
题目:编写一个程序,提示用户从键盘输入一个星期的薪水(以美元为单位)和工作时数,他们均为浮点数,然后计算并输出每个小时的平均薪水,输出格式为:
Your average hourly pay rate is 7 dollars and 54 cents.
下面是我写的 不知道对不对
#include<stdio.h>
int main(void)
{
float week_hours_work=0.0f;
float week_time_work=0.0f;
float week_salary=0.0f;
float salery_per_hour=0.0f;
float hour=0.0f;
const float RMB_per_dollar=6.7f;
const float hours_per_day=24.0f;
printf("Please enter your salary of one week: ");
scanf("%f",&week_salary);
printf("Please enter your work time of one week: ");
scanf("%f",&week_time_work);
week_hours_work=24.0f*week_time_work;
salery_per_hour=week_salary/week_hours_work;
printf("Your average nourly pay rate is %ld dollars and %.2f cents",salery_per_hour/RMB_per_dollar,salery_per_hour%RMB_per_dollar);
ruturn 0;
}
搜索更多相关主题的帖子: 用户 
2008-10-17 22:00
lovekinglet
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2008-10-17
收藏
得分:0 
#include<stdio.h>


int main(void)
{
float week_hours_work=0.0f;
float week_time_work=0.0f;
float week_salary=0.0f;
float salery_per_hour=0.0f;
const float rmb_per_dollar=6.7f;
const float hours_per_day=24.0f;
float dollars=0.0f;
float cents=0.0f;
printf("Please enter your salary of one week: ");
scanf("%f",&week_salary);
printf("Please enter your work time of one week: ");
scanf("%f",&week_time_work);
week_hours_work=hours_per_day*week_time_work;
salery_per_hour=week_salary/week_hours_work;
dollars=salery_per_hour/rmb_per_dollar;
cents=salery_per_hour% rmb_per_dollar;
printf("Your average nourly pay rate is %.0f dollars and %.2f cents",dollars,cents);
return 0;
}
看看对不对呀
2008-10-17 23:00
lovekinglet
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2008-10-17
收藏
得分:0 
dillon 你好
你的这个程序好多东西我还没有学到
所以 能写个简单点的吗
谢谢了
2008-10-19 11:46
lovekinglet
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2008-10-17
收藏
得分:0 
#include<stdio.h>
void main()
{
    int i;
    float a[7],b[7];
     float x=0,y=0,z;
    printf("enter your worktime and money :\n");
    for(i=0;i<=6;i++)
    {
        scanf("%f %f",&a[i],&b[i]);
        x+=a[i];
        y+=b[i];
    }
    z=y/x;
    printf("Your average hourly pay rate is %f:\n",z);
}
这个程序我测试了一下 输出不了要求的结果.也可能是我没有搞明白.
2008-10-19 11:58
快速回复:求编个程序 谢谢
数据加载中...
 
   



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

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