1 喜歡 1 不喜歡
8.9k 瀏覽

A water supply company charges the water consumption, as follows:

a) Fixed amount of 10$.
b) For the first 30 cubic meters 0.6$/meter.
c) For the next 20 cubic meters 0.8$/meter.  
d) For the next 10 cubic meters 1$/meter.  
e) For every additional meter 1.2$/meter.   

Write a program that reads the water consumption in cubic meters and displays the bill.
寫一個輸入水的用量 輸出水費的程式

Example Input:

25

Output:

Cost: 25.00

Example Input 2:

44

Output:

Cost: 39.20

Example Input 3:
 

75

Output:

Cost: 72.00

 

[考試] 最新提問 分類:Midterm | 用戶: (12.1k 分)
ID: 32351 - 從幾時開始: 2017-11-15 14:10 - 到幾時結束: 無限制
| 8.9k 瀏覽

59 個回答

0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
#include <stdlib.h>

int main()
{
**** ** **** * * ** * * a;
* *** ** * ** * * ** * * * ** ** ** ***** *
**** ** * * ** * * ***** * *
* * * * ** ** * ** * *** ** * * *** ** ** * **** %.2f",10+a*0.6);
** * ** ** ** * * * *** ** ****** * *** * * ** *
* * *** **** ** ** *** * * * ** *** *** ****** * %.2f",10+18+(a-30)*0.8);
* * ** * * * * *** ** * ** * **** *
* ** ** * * * ** ** * **** * * ** *** ** ** * ** %.2f",10+18+16+(a-50)*1);
*** ** ** * ** * ******** *** *
****** * * * *** * * ***** * * ** * *** * **** ** * * * * * * * **** * * * * ***
****** *** ** * *** ** * 0;
}
最新回答 用戶: (-258 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
#include <stdlib.h>

int main()
{
    float a;
**** * * *** * * * ** * * ****** *** ****
*** * ***** ******** ** *** * *** **
* ** * ** * ** * ** * *** * * * *** ****** *** * *
* * ** **** *** ** *** **** * ******* ** *
* ** * *** ** * * * * * ** * * * * ** * ** * * ** * * ** ** ** *
* ** * * ** * *** ** * * * ****** * ****
* * ***** * * ** * * * * * ***** ** **** * * ** ** ** ** ** ** * *
* * * * * ** * * * * **
******** * * *** **** * ***** ** * *** ** **** *** * * * *** ** ***
    return 0;
}
最新回答 用戶: (-258 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a;
* * * * * ** *** * ** ** * **** * ** *** * ** *
* *** ** *** * ** * ****
* * ** * * * * * ** ** * * ** * *** * ***** ** * * * * * **
*** * ** * * ***** * * ***** * ****** * *** *
* * * * * * * ** ** ** * * * * **** * ** * * * *** *** * ** *
** **** * * * * * * * * **** * ** ** * ***** *
** * * ** * *** * ** ** * * * * * ** * *** * **** ** ** ********** ** *
* * * ** **** **** ** ***
** * ** * *** * * ******* * *** * ***** * * * ** ** *** * ***** * * ** * **
    return 0;
}
最新回答 用戶: (-258 分)
0 0
prog.c: In function 'main':
prog.c:7:13: warning: format '%f' expects argument of type 'float *', but argument 2 has type 'int *' [-Wformat=]
     scanf("%f",&a);
             ^
prog.c:13:20: warning: format '%f' expects argument of type 'double', but argument 2 has type 'int' [-Wformat=]
         printf("%.2f",10+18+16+(a-50)*1);
                    ^
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
int main()
{
* * ** ****** *** * a;
*** ***** * *** ** * * b;
* * **** * ** * * * * **** * * * &a);
** **** * ** *** * * a<=30 )
* ***** * * ** *** * * * *** * * * * ***** * * * *** **
* ** *** * ** ** * * **** * * *** ** if (a<=50)
*** ** *** * * * * * ** ** * * * ** * ** * **** * * ****
** * * * * ***** * *** * * ** * * * * * if (a<=60)
** * * * **** *** *** ** * * * * * * ** * ** * ** * **** ** * * ** *
** *** * * * * ** * **** ** * *** * *** * * * b=10+30*0.6+20*0.8+(10)+(a-60)*1.2;
** * * * **** * ** * * * ** * ***** ** ***** * **** %0.2f", b);
* * **** * * * * * **** * * 0;





}
最新回答 用戶: (-140 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include * * *

int main(){
* *   float fix = 10.0;
* ** ** ** * ** float n=1.2, n10=1.0, n20=0.8, n30=0.6;

******   float a;
* * * * float cost;

* *   ** ** * * ** **

*** ***   *** * *
** *** *** *** * ***** * * * * * * ** * = * **

* ** * ** * * *** * *** * * *
***** * ** ** ****** *** ****** * ***** * **** ***** = *** * * ***

** ** * * **** ** * * ** * ** * **** * * ** ** *
* ** ** * * ** * *** ** *** * * *** *** = **** *** **

* ** * ** * * * ** ** * * *
* *** *** ** * * ** **** ** *** = * *** ** * * * ** * * *

* * * ** * * ** * ****** ***** * *** * ** **** cost);

* ***   return 0;
}
最新回答 用戶: (-74 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include * ** * ***** *

int main(){
* ***   float fix = 10.0;
** * ***** float n=1.2, n10=1.0, n20=0.8, n30=0.6;

* *   float a;
** ** ** ** float cost;

****   * ***** ***** ****

** * *   *** ** *
* ****** ** * *** ** ** *** * * *** ** * ** = *** * *

** ** * * *** * * * ** * ****** * ** * **
* * ** * *** ** *** ** * ***** * **** * = *** *** ***

* ****** ** * * * ** ** ** * *** *** * * ** * *
*** * * * *** *** * ** ** * * ** ** = * * * ***** * **

******** * * * * ** * *** ***
** *** *** * ** * ** ** * ** * ** * * ** ** = * ** * * * * ** ***** *

** * ** ** ** * * * * ** ** *** *** * cost);

* * *   return 0;
}
最新回答 用戶: (-74 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include * * * *

int main(){
*   float fix = 10.0;
* **** * float n=1.2, n10=1.0, n20=0.8, n30=0.6;

*** * * * float a;
** ** * *** * float cost=0;

** ****** * * * ** * ** ** ** *

* * * **** * * * **** *** **
** * *** **** ** ** * * * ** ** **** ** * ** * *** = fix+n30;

** *****   *** *** ** ** ** ** * * *
** * * * * *** **** ** ** ** * ** ** ** **** = *****

* ** ** * ** ***** ** * *
** * ** * ** ** * ** * * * * * * * = * * *

* ** * ***** * * ****** *** * *** * * **
**** * * **** ** * *** ** ***** * * ****** = ** ** ** *** *

* ** * *** *** * *** *** ******* * * cost);



* *   return 0;
}
最新回答 用戶: (-74 分)
0 0
prog.c: In function 'main':
prog.c:10:10: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'float *' [-Wformat=]
  scanf("%d",&a);
          ^
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
int main (void)
{
    int a,j;
** * ** ** * *** * *** * * * s;
* ** **** * * ** * ****** ** * * * * ** ** *
** * ** * ** *** * ** *** * ** && a<=30)
* **** * * * * * *** ** ** ** *** * ** * *** * **
* * * ** ******* ** ***** ** * ** * ** *** (a>30 && a<=50)
*** * *** *** * **** * ** ** * * ** **** ***
* *** * ** *** ** * * ** * ** **** ** (a>50 && a<=60)
*** * ** **** * *** ** *** * * * ** *** ** **** *
* ** ** ** * ** *** * ** *** *** ** (a>60)
** * * * *** * * * ** ** ******* ***** * * * * * * * * * * *** * *
*** ***** * ** * ******* *** *** * * * * * *
* * * * ** * * ** * * **** ** * ** ** ** * * * %.2f",s);
*** * * * * ** * * ** ****** *** * * * * * **** * * 0;
}
最新回答 用戶: (-32 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
int main (void)
{
    int a,j;
    float s;
* *** * * **** * * * * * * *** *** ** *** ***
    if(a>0 && a<=30)
**** * *** ** *** * **** * ****** * * * * ***
* * ***** **** * * ** * *** * *** *** ** * (a>30 && a<=50)
* * * ** * ** * *** * * **** **********
** ** ** ** ****** *** * *** *** * *** ** * ** * ** * ** * * * **
** * ***** *** * **** ** * ***** * ** ***
**** * *** * * **** ** ** *** * ** * **** (a>50 && a<=60)
*** *** *** * **** ****** * ****** ****** * ***
* ****** * *** * ******** * * * ** ** * * *** * *** ** ** ** * * * * ******* * ******
** * ** * *** ***** ** *** * *** * * *
*** ** ** * ** ** *** ** * * ** ** * * (a>60)
**** * * * **** ** * * ** * ** *** * **
** ** * * **** * ** * *** * ** **** ** * ** ** **** ** * * ** *** **** ** ****** * * *
* * ** * ** * * * *** ** * ** * * ****
*** ** * * * ** * * * * * * * * * ** *
** * ** * ** ** * * ******* ** *** **** ********* * %.2f",s);
**** ** * *** * ** ****** * * * *** * ***** ** * * 0;
}
最新回答 用戶: (-168 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
#include <stdlib.h>

float main()
{
** ** * * **** ** a,b,c,d,e;
**** * * * ** * * * * ** * * ** ******* * * *
* * * * ** ** * *
** * * * * ** ****
* ** * * * ** * *** * *
* * ** * ***** * ***


* * * * * * ***** ** (a>0,a<=30)
*** ** * * * * ** *** * *** * * * * **** * ** * %.2f",a*0.6+b);

* * ** ** * ** ** * * **** * * * ** ** (a>30,a<=50);
******* * **** ****** ** *** ***** ** ***** * * *** * * *** *** ******* *



* ** * * ****** * ** * (a>50,a<60)
** * ** **** * * **** * ** ** *** ** * * ** * * * **** * ** * *
* ** ** *** * ****** * * ** *** * *** * ******** * (a>=60);
* ** *** ** * * * * * * ** * * ** *** **** ** * ** *** * ** * * ** * * **** **

*** ** *** ** **** ** 0;
}
60/100 最新回答
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.179.76
©2016-2025

相關問題

0 喜歡 0 不喜歡
19 回答
[考試] 最新提問 12月 9, 2017 分類:Midterm | 用戶: thopd (12.1k 分)
ID: 36750 - 從幾時開始: 2017-11-15 14:10 - 到幾時結束: 無限制
| 3.5k 瀏覽
0 喜歡 0 不喜歡
15 回答
[考試] 最新提問 12月 9, 2017 分類:Midterm | 用戶: thopd (12.1k 分)
ID: 36755 - 從幾時開始: 2017-11-15 14:10 - 到幾時結束: 無限制
| 3.2k 瀏覽
0 喜歡 3 不喜歡
58 回答
[考試] 最新提問 11月 15, 2017 分類:Midterm | 用戶: thopd (12.1k 分)
ID: 32710 - 從幾時開始: 2017-11-15 14:10 - 到幾時結束: 無限制
| 8k 瀏覽
12,783 問題
183,442 回答
172,219 留言
4,824 用戶