0 like 0 dislike
2.7k views

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

 

[Exam] asked in Midterm by (12.1k points)
ID: 36750 - Available when: 2017-11-15 14:10 - Due to: Unlimited
| 2.7k views

19 Answers

0 like 0 dislike
Hidden content!
* * *** ** ***
int main (){
int a,b,c;
float ** *** * *****
* * * ** first your * * * * ****
*** *** * ***** * **
* ** ***
** * * * * ** * * * ****
***** * second your meters: **** **
* * *** * * ** ***
* * ** *** **
* * * * ** *** * ** * *
* * * **** second your meters: *** **
* * * **** * ** *** ** *
** ** ** ***
* ****** **** * * * ** *

return 0;
answered by (16 points)
0 0
prog.c: In function 'main':
prog.c:18:1: error: expected declaration or statement at end of input
 return 0;
 ^~~~~~
0 like 0 dislike
Hidden content!
#include<stdio.h>

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

* * *** *** *** ** *** * ** ** * * %.2f",t);
}
answered by (-32 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{

* ****** * * ****** * * * ** usage,cost,contant=10;

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

* **** ** ***** ** * * (usage>0 && usage<=30){
** * ** * * ** * * * ** * ** ** *** **** contant);
**** * * * ** * ** * *** * * ** ** * * * * * **** * ** * %.2f",cost);
**** * * * *** * ****** ** *
* * ** **** ** * ** ** ** * ** && usage<50){
**** * ** * * *** * * * * * * ** *** * * *** + (30*.6)+ contant;
* ** ***** * * * ** **** *** ** ** ** * * %.2f", cost);
* *** ** * ***** *** *
* ******** * ** ** * * ******** * * * *** * ***
* ***** ** ** *** * ***** * * *** ** ** * *** * *** *** ** ** ** ** **
*** * **** * * * * ***** * *** * ** *** * * **** %.2f",cost);
**** *** * * ** **
** * * ** **** ** * if(usage>60){
* * **** * * * ** ** ****** * ** ** *** * *** ** ***** ***** **** ** *
**** * * ** * * * ** * * * * * ** * ** * ********** %.2f",cost);
**** * * ** * ** ***** **
* * * * * * **** * 0;
}
answered by (-167 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main()
{
* * * * * ** ** ** ** wc;
******* *** * * * ** * ****** total=0;
* **** **** * *** **** ** tab1;
* * * * ** * * ** * tab2;
** ** * *** ** * * ***** nt;
** * * ** * * ** *** * * ** nt1;

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

** * * ** *** ** ** ** * * *
    {
* * * * ***** *** *** * **** * ** ** * **** ** * *
    }

* ** ***** * ** * ** ** ** * ** * **
    {
** ** * * * * * * * * * ** * * *** * *** ** *** * ** ** *
* *** *** *** * * ** ** ** ** *** * **

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

* * ** ** * *** * * ** * * *** * * * ** ** ***
    }

* * **** ** ** *** ***** ***
    {
* * ** * *** ** * *** ** *** *** ******** * * ** ** * * **

* * * * * ** ** * *** * * * * ******* ** * * * ** *** ** * * * *
    }

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

return 0;
}
answered by (-193 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main()
{
*** *** * ** * * wc;
** ****** **** ****** total=0;
****** * * * * * * tab1;
*** * * ** * * ** * ***** tab2;
** * ******** ** * ** * nt;
    int nt1;

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

** **** * * * ** * ** * **
    {
** * ** * ** **** * * ** *** *** * * ** *** ** ***
    }

*** ** * *** * * * * ***** * ** * * **
    {
** * * * ** ** ** ** **** * * * * *** * ** *** *
* ** * * *** * * ** ** * *** ** *** * *

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

** ***** ** * ** * * * * * ** *** *** * ** * * ** ***
    }

** * * ** * *** * **** * * *
    {
* **** * ** * *** ** ** ** * * *** * * ** * * *

*** ** * * * * ** * ** * **** * *** * **** * * ***** * *** *
    }

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

return 0;
}
answered by (-193 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
    int water;
    float cost;
* * ** **** ** ** * *** * ** * amount;

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

* ** * **** ** *** * **** && water<30){
** *** * *** * ***** *** * ** * * * *** ** **** = (water * 0.6) + 10;
** ****** * *** * * * ** ********* ****** ** **** * * * ***
** * * * ** * *** * ** * ** * ** ** * ** * && water<50){
* * *** * ** * * ********* * * ** * * * * ** * ******** *** * * * * ****
** ** *** * * ** * *** * ** ** * * ** * * ** *** ** * ** * * * * *** ** ** * **** * *
* * ** **** * * * * ** * **** * * *** ** * * * * * && water<60){
*** ** ** * ** ** * * ** **** * *** * ****** *** * * * *** ** **** ** * * * ** ******
**** ** ** * **** * ** * ** * * ** ** * * ***** * *** ** ****** ******* * * * ** *** * * **
** *** * * *** * * * * * * * *** * ** * **** *** * * * *
** * *** * * * * * * *** *** ** ** ** **
** * ** * * **** ** ** * * * ** * *** ** **
    return 0;
}
answered by (-167 points)
0 0
prog.c: In function 'main':
prog.c:8:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
     scanf("%d",water);
             ^
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
** ** ** * ** ** ** a,b;
* ** *** * * ** *** *** * ** ** **
******* * * * *** * **** **
    {
* **** * * ** * * * * * ** ** * * * ** * * ** *
** ** *** * * ** * *** *
* ** * *** ** * **** *** * ***** *** ***
***** * * * ** * ** * **
** * ** *** ** ** * *** ** * * * **** * * ** ** ** * *
* *** ** ** ***** *
* * * * ** * * * * * **** *** * **** * *** * *
** ** ** * * ** **
* * * * * ** * ** * * ** * ** * ** ** ** * * ** ***
    }
* ** *** * *** **** ** if(a>=60)
** ** * * *** * * *
** * *** ***** * * *** * ** *** **** * * * ** ** *** ** ** *
    }
* * * * * * * *** * * * %.2f",b);
}
answered by (-255 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main()
{
* ** * **** * * **** * a;
**** *** ***** ** ** **** * * *** * * ***
* * ***** ** * ****** ** (a<=30)
* *** * * *** * * * **** ** * ** * ** * * * * * **** * %.2f",10+a*0.6);
* *** * * * *** * * if(a<=50)
* **** ** * * ** * **** *** **** **** *** * *** ***** * ** * **** *** * * ******* **
* * * ** ******** * if(a<=60)
* ** * * * * ** * * * ***** *** * * ******* * * **** ** ***** * ** * * ** *
** **** ** ** * * ** if(a>60)
*** ** * * *** * **** * **** ***** * ** * * * * *** ****** * * * **** ****
** * **** *** * 0;
}
answered by (42 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main()
{
** ** *** * * * **** * a;
** * *** *** *** * * * * **** ******* *** ** ** *
* ** * * * **** * (a<=30)
** * *** ** * * * **** * *** * *** * ** %.2f",10+a*0.6);
**** * ** * * * * *** if(a<=50)
* * *** ** * * * ***** * * ** * ** **** ** * * * ** ** * ** * **
* * **** *** ******* * ** if(a<=60)
* ** * * * ** * * *** *** *** * * * * * * * * ** * **** * ******** * * *** *
* **** * * **** * ** if(a>60)
*** *** ** ****** ** ** ***** * * **** * * ** ** ***** * * * ** *** *
******** **** * ** * * 0;
}
answered by (-108 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main(void)
{
* ** ** ** * * * * c,total;
* ** * ** * ** *** ** *** * ** ** **

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

* * *** ** *** if(c>30 && c<=50)
** * * * ***** *
** * * * **** * ** * * * *** * ** * * * * ***
* ** **** *** *** * * *** ** ** ** ***** **** ** %.2f",total);

* * ** * ** **
* * ** **** * **** ** if(c>50 && c<=60)
*** ** * **
*** *** ***** * * * * * **** ** ** *** *** * ** *** * ****
*** ** ** ** * *** * ** ** ** ** * * * %.2f",total);
* ***** * *** ***
** * *** **** * *******
** * ***** * * ***
* ***** * ** *** * ** ** ** **** ** ** * ***** ******
* ** * * *** ** *** * * * * ** * ** *** **** %.2f",total);
* * * ** *** **




}
answered by (-249 points)
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.71.254.20
©2016-2025

Related questions

1 like 1 dislike
59 answers
[Exam] asked Nov 15, 2017 in Midterm by thopd (12.1k points)
ID: 32351 - Available when: 2017-11-15 14:10 - Due to: Unlimited
| 6.9k views
0 like 0 dislike
15 answers
[Exam] asked Dec 9, 2017 in Midterm by thopd (12.1k points)
ID: 36755 - Available when: 2017-11-15 14:10 - Due to: Unlimited
| 2.6k views
0 like 3 dislike
58 answers
[Exam] asked Nov 15, 2017 in Midterm by thopd (12.1k points)
ID: 32710 - Available when: 2017-11-15 14:10 - Due to: Unlimited
| 6.3k views
0 like 0 dislike
21 answers
[Exam] asked Dec 9, 2017 in Midterm by thopd (12.1k points)
ID: 36754 - Available when: 2017-11-15 14:10 - Due to: Unlimited
| 3k views
0 like 0 dislike
22 answers
[Exam] asked Dec 9, 2017 in Midterm by thopd (12.1k points)
ID: 36753 - Available when: 2017-11-15 14:10 - Due to: Unlimited
| 3k views
12,783 questions
183,442 answers
172,219 comments
4,824 users