| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 594 人关注过本帖
标题:这个怎么编写
只看楼主 加入收藏
wuwenkai
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-10-19
收藏
 问题点数:0 回复次数:4 
这个怎么编写
Write a program that will calculate and print bills for the city power company. The rates vary depending on whether the use is residential, commercial or industrial. A code of R means residential use, a code of C means commercial use and a code of I means industrial use. Any other code should be treated as an error. The rates are computed as follows:
R: ₤4.00 plus ₤0.03 per kwh (kilowatt-hour) used
C: ₤40.00 for the first 1000kwh and ₤0.025 for each additional kwh.
I: Rate varies depending on time of usage:

    Peak Hours:         ₤50.00 for the first 1000 kwh and
                 ₤0.04 for each additional kwh

    Off-Peak Hours:     ₤30.00 for the first 1000 kwh and
                 ₤0.02 for each additional kwh.
Your program should prompt the user to enter an integer account number and the use code (type char). Depending on the account type selected the user should be prompted to provide the consumption figures in whole numbers of kilowatt-hours. The program should display the account number and the amount due from the user.
The calculation of the amount due for each account type should be performed by three functions:
1.    residential: a function that returns a double and takes an input argument of type int This function should be used to compute the bill for residential customers.
2.    commercial: a function that returns a double and takes one input argument of type int. This function should be used to compute the bill for commercial customers.
3.    industrial :  a function that returns a double and takes two input arguments of type int (peak and off_peak). This function should be used to compute the bill for industrial customers.  
 
大哥 大姐们。。这个怎样编写呀。。谢谢啦。。十分感谢
搜索更多相关主题的帖子: 编写 
2008-10-29 11:58
zxwangyun
Rank: 4
来 自:云南
等 级:业余侠客
威 望:1
帖 子:232
专家分:299
注 册:2008-10-17
收藏
得分:0 
此生最怕english
2008-10-29 13:10
flamemiracle
Rank: 2
等 级:论坛游民
威 望:1
帖 子:121
专家分:51
注 册:2008-10-25
收藏
得分:0 
你是不懂题啊,还是不会些程序哦,这英语看起来也够繁琐的了
2008-10-29 13:46
phoebe_candy
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-10-21
收藏
得分:0 
#include "stdio.h"
float Res(int i)
{float due;
    due=4+0.03*i;
    return(due);
}

float Com(int i)
{float due;
    if(i<=1000)
    due=40;
 else
     due=40+0.025*(i-1000);
 return(due);
 }
 
float Ind()
{ int a;
   int b;
   float da,db;
 printf("enter the consumption figures for Peak Hours:");
 scanf("%d",&a);
 printf("enter the consumption figures for Off-Peak Hours:");
  scanf("%d",&b);
 
if(a<=1000)
    da=50;
 else
     da=50+0.04*(a-1000);
 if(b<=1000)
    db=30;
 else
     db=40+0.02*(b-1000);
return(da+db);
}


main()
{int num;
char type;
float due;
int cf;
printf("please enter an integer account number and the use code (type char):\n");
scanf("%d,%c",&num,&type);
printf("please enter the consumption figures in whole numbers of kilowatt-hours:\n");
scanf("%d",&cf);
switch (type)
     {case 'r': due=Res(cf);break;
      case 'c': due=Com(cf);break;
      case 'i': due=Ind(cf);break;
      default: printf("error!\n");
     }
    printf("account number:%d\nthe bill is:%6.2f\n",num,due);
}
2008-10-29 14:44
phoebe_candy
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-10-21
收藏
得分:0 
这个程序不难主要是看懂题,题目要求是将电费分类计费:居民用电(r)、商业用电(c)和工业用电(i)。
要求:
1.提示输入用户消费序号及用户类型(r、c、i);
2.提示输入用户消费的电量(度);
3.显示该用户的消费序号和总消费额。
4.程序通过3个函数完成。上面给出的程序中三个函数分别是: Res(),Com(),Ind()

以上是我的理解。
2008-10-29 14:54
快速回复:这个怎么编写
数据加载中...
 
   



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

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