1 喜歡 0 不喜歡
14.4k 瀏覽

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

 

[練習] Coding (C) - 最新提問 分類:Chapter 4: Expressions | 用戶: (12.1k 分)
ID: 26465 - 從幾時開始: 無限制 - 到幾時結束: 無限制

修改於 用戶: | 14.4k 瀏覽

91 個回答

0 喜歡 0 不喜歡
內容已隱藏
* *** * * *
int main()

{
* * * * ** *** ** * *** meters, cost;
* *** * * ** ** * * *** * * * ** ** * * * &meters);
* * * ***** ** * * *
** * * * * * *** * ** ** **** * <= 30)
* ****** * * *** * ** ** ***** * * *** *** * * * **** = 0.6*meters;
* * ***** * ** * ** * * * if(meters <=50)
* ** ** **** **** * ******* ** **** * *** * * = 0.6*30 + 0.8* (meters -30);
* ** * ***** ******** if(meters <= 60)
* ** ***** *** * ** * ** * * ** * * * * ** ** = 0.6*30 + 0.8*20 +1*(meters-50);
* * * * ******* * *** **
* *** * * ** *** * *** * * ** * * = * * * *** * ** *** ;
* * * * ** ****
** **** * * * * * ** += 10;
* * ** ** *** ** * *** ****** * %.2f\n", cost);
***** * ***** ** *
*** ** ******* * * 0;
}
最新回答 用戶: (-233 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
* *** *** ** **
int main()

{
* * * *** ** * *** ** meters, cost;
* ** **** * * **** ** **** ** * ** ** &meters);
** ******* *** * * *
* ***** * * * * * * * **** <= 30)
** * ********** ** * * ** * * *** ******* *** ***** * = 0.6*meters;
* ** ** * *** ** * if(meters <=50)
* **** **** * ** ***** ** * * ** *** ** = 0.6*30 + 0.8* (meters -30);
* ** * * * ** * * *** **** if(meters <= 60)
* *** * * ** * * ***** *** * ** * * * * * ** ** = 0.6*30 + 0.8*20 +1*(meters-50);
* **** *** ** * * * * * **
**** * * *** * ** ** ** ** *** * *** ***** = ******* *** ;
* * * *** * ** * * *
* * * * * *** * * * *** * += 10;
** * * * * * *** * *** * * %.2f\n", cost);
** *** *** *** * *****
** ** * * **** ** ** * * 0;
}
最新回答 用戶: (-233 分)
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>
int main()
{
    int a,b;
* **** ** ** * * ***** total;
*** ** * * **** *** * **** ** ** ** ** * *
* ** ****** * * * * * *** * ** ***** * **
* **** * * ** *** * ***** * * ** * *** ** * ** * *
* * *** ***** ** ** *** * * ** * * * * **** * ** * *
* ** * * * *** ** **** **
**** ** * ** * ** * * * *** ***
* * ** ** ** ** * *** ** ** %.2f",total);
** **** ** * *** * **** * 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 **** ***
int main (){
int a,b,c;
float * *** ******
* ** ** *** * number");
* *** **** * * **
total1=10+a*0.6;
** ** * *** ***** * **
***** ** ** * ** * * * ***
* ** *** * **** *** ***** *
* *** *
* *** * ** * ** *
** ** * ** * ****
** ***** * *** ** * * ** ***
*** *****
* * * * * * *** * *** * * *

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

* * * * * * ** ** ** ****
*** ** ******** ** * ** *** ** *** *** + 30*0.6 + 20*0.8 + (60-a)*1;

* ** * ** * * **** *** ** ******
*** * * * *** **** ** **** * *** * + 30*0.6 + (a-30)*0.8;

** ***** * * ** ** * * * *
*** ** * * * * * *** *** * * * ** *** * ** * ** ** * + a*0.6;


******** ** * * * ** *** * * * %.2f", t);

* * * **** ** ** * 0;
}
最新回答 用戶: (-32 分)
修改於 用戶:
0 0
prog.c:2:2: warning: return type defaults to 'int' [-Wimplicit-int]
  main()
  ^~~~
0 0
prog.c:2:2: warning: return type defaults to 'int' [-Wimplicit-int]
  main()
  ^~~~
0 0
prog.c:2:2: warning: return type defaults to 'int' [-Wimplicit-int]
  main()
  ^~~~
0 0
prog.c:2:2: warning: return type defaults to 'int' [-Wimplicit-int]
  main()
  ^~~~
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
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()
{
*** ** * *** * ** * *** * * ** a,TOTAL=0;
** * *********************** ** *** ** ****
****** ** * ** * * ** (a<=30)
****** ** * **** ** * * ****
** * * * **** * *** *** * * * * * * * *** *** *** *
*** * ** ** * * * **** **** * ** * * * * * * * ***** * %.2f",TOTAL);
*** ** *** * *** **
** * **** * * * *** if (a>30 && a<=50)
*** * * * * * ****
* ** * * * ** * ** * **** *** *** *** ******* *
** *** * * * * *** ** *** * * * * * *** * * ******* * * %.2f",TOTAL);
* * * * ** * * ** *
* ** * *** * * * * if (a>50 && a<=60)
*** ** ** ** * * **
* ** * **** **** * ** * **** * ***** * * * ** * **
* * ** * * * **** * * * * ***** **** ******* * *** * %.2f",TOTAL);
* *** * *** * * *****
**** ** ** * * if (a>60)
* *** ** ******* * ** **** *
**** * *** * * * * * ** * *** * * * ** * ** *** ** * **** *
* * ***** * **** * ** * * ** **** * ** * **** * * * * %.2f",TOTAL);
    }
}
最新回答 用戶: (-214 分)
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()
{
    int meter;
    float cost;

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

* **** * ***** * **** * ** * * **
**** * * *** * * *** **** *** * ** * * ** * * ***** * ** *
** ** * ** * * ** *** * **** ** * ** ** **** * ** **** * * * ** %.2f",cost);}
    else
* * * * * **** * * ** **** * * *** ***** * * *** ** *
* * * * ** **** ** * * ** * * * * **** * *** ** ** ** ** ** * * * * * * *** *** * *
* ***** * ******* ** * * * ** * * **** ***** * * **** * *** %.2f",cost);}
**** * * * *** * *** * *** ** * * ****
* * * * * ** ** *** * * ** * ** * * * * * * * * * * * * * ***
* * *** * * ** *** ** *** * * ** * * * * *** ** * * **** * * * * * * ***** * **** * * ** **
* ** * ** ** * ***** * * * * ** ** * ** * ** ** * ** ** * * * ****** ** **** *** * **** * ** *** * * %.2f",cost);}
* * ** ** ** ******* ***** *** ** ** ** * * * * ** **** * ** ** * ** *
** * * *** ***** *** * * * * * * **** * * ** ** **** *** *** * ** * ** ***** ** ** ** * ** * *** * * ** * *** *
* ***** * ****** ** * *** ****** * * * ***** ** *** ** * ** * * * * * ** ** ** * **** * %.2f",cost);}

    return 0;
}
最新回答 用戶: (-16 分)
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()
{
* * * * **** ** *** ** * a,b,c;
* *** * *** * * ******* *** ***
* ** ** * ** * *** * ** *
* ** ** ** ** ** *** ****
* **** * *** ** ** * * * * ****** ***
* *** ****** ** * ** *
* ** ** * * *** if(a<50)
* * * ** * ** **
* * * *** * * ** * ** * * * * ***** * * * * * * ** **
    }
* * * * * ** *** * ** if(a<60)
    {
* *** ** * * * ** ** * * * ***** * * ******* *
    }
* ****** * * * ** **
***** * * * * **
* ** * ** **** ** * *** ***** *** * * ** ** * * * ** * **** *** * * * * *
* * * * * * *
* **** *** * *** * ** * * * * %.2f",c);
}
最新回答 用戶: (-329 分)
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()
{
**** **** * ****** * a;
* * * * ****** ** ** *** * ** * *******
* *** * ***** ***** ** * ** ** * * *** *
*** ** * ** *** * **** * * *** * * * *** * ** * %.2f",10+0.6*a);
* ****** ** * ** ** * **** ** * **** ** * *
*** ******** **** ** ** *** * ******* ****** *** ** * ***** * %.2f",28+(a-30)*0.8);
*** * * * ****** **** * ** * *** ** * * * *** ** * *
** * * ** * * * * * *** ** * ** * ** * * * ** * * * ** * * %.2f",44+(a-50));
* * *** ** * ** * ** *
* * **** ********* ** *** * * * ** *** * **** ** ** *** ****** %.2f",54+(a-60)*1.2);
*** ** ***** ** * * ** 0;
}
最新回答 用戶: (-498 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.58.115
©2016-2025

相關問題

3 喜歡 0 不喜歡
87 回答
[練習] Coding (C) - 最新提問 10月 12, 2017 分類:Chapter 3: Formatted Input/Output | 用戶: thopd (12.1k 分)
ID: 26463 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 11.5k 瀏覽
3 喜歡 0 不喜歡
86 回答
[練習] Coding (C) - 最新提問 10月 5, 2017 分類:Chapter 4: Expressions | 用戶: thopd (12.1k 分)
ID: 25730 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 10.2k 瀏覽
12,783 問題
183,442 回答
172,219 留言
4,824 用戶