1 like 0 dislike
7.9k 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

 

[Exercise] Coding (C) - asked in Chapter 4: Expressions by (12.1k points)
ID: 26465 - Available when: Unlimited - Due to: Unlimited

edited by | 7.9k views

91 Answers

0 like 0 dislike
Hidden content!
#include <stdio.h>

int main(){

    float a,b,c,d,e;

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

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

* ** * ** * ***** *** * *** * ** * * * * && a>30){
** * ****** * *** * ** * *** ** * ** *** *** *** * * * * * **

* *** * *** * * * *** *** * ** ******* * * ** && a>50){
**** * * ** * * * ** ** *** ****** ***** *** * **** **** * *

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










    return 0;



}
answered by (-301 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>
#include <stdlib.h>

int main()
{
** *** * * ** ** * * *** ** a;
** **** ** *** **** *** * **** * * ** ** *
* * *** * * * * * * * * * * * *
** **** ** *** * *** ***** * * ***** * ** *** * *** %.2f",a*0.6+10);
**** ** ***** ** ***** *** if(a<=50)
** ** * * **** * *** *** * * ** * * ** * * * ****** %.2f",(30*0.6)+(a-30)*0.8+10);
* ** * * *** ** * *** *** if(a<=60)
*** ** * ** * ** * * ***** *** ** * * ****** ***** * * * ** * *
* * * **** * * * ** * ***** *
* * * ** * ** **** * ** * ** * * * ** * ***** *** ** *** * * * ***** * **** * ***
**** * * * * * * 0;
}
answered by (-258 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 0
-----------Re-judge-----------
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 * * ** * **

int main ()

{
**** * **** *** * * *** * userinput, a, b, c, extra;

* *** * * ** ** ** * * *** &userinput);
** ****** * * *** * * (userinput<31)
** **** *** * * * ****
** * * *** ** ***** * * * ** ** ** ** * * * * = userinput * 0.6;
** ** ** * * ** * * * * * * ** * ** ** * * * * *** * * %.2f", a+10);
** * * ** * **
**** ** *** *** * * *** if (userinput<51)
* * * * ** * * ** *
* * ** * * * ** * * * * * * * ****** = (userinput - 30)*0.8+30*0.6;
** ****** ****** * *** *** * ** *** * * ** ** * * %.2f", b+10);
*** ** ** * * ***
* ** ** * ** ***** * * if * ** * ** * *
* ** * * ** * * * ***
** **** ***** * ** * *** * *** * * ** **** = (userinput - 50)*1+30*0.6+20*0.8;
* * **** * *** ***** * **** * *** * * * ** * * * * ** %.2f", c+10);
* * ** * ** * *** * **
** * * ** * * **
* **** * * **
** ******* * ** ****** * * ***** * ** *** ** * * * = (userinput - * * ** * ****
** **** ** ** * **** ** ** * ** ** ** ** %.2f", extra+10);
** * ** ** ** *


* * *** * ** *** * ** 0;

}
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
0 0
-----------Re-judge-----------
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!
***** *** * ** *
#define FIXED_AMOUNT 10
int main()
{
* * *** * *** ** ****  x, first_30cb, **** * ** next_10cb, add_metercb;
* * * * *** ** ** * *** * *** ** &x);
* ***** * * (x<31)
******* * ****
* ** * * ***** ** * **** * * * ** * ** = FIXED_AMOUNT + x*0.6;
* **** * **** * *********** ** * ** ************* * * * *** *
**** * *** * **
** * ** ** * if (x<51)
**** ** ** * * *
** * * ** ****** ** ** *** * *** *** = FIXED_AMOUNT + (x-30)*0.8 + 30*0.6;
* * ***** *** ** ** ** * *** ** * * * ** ** * * * ** * ** **
* * ** *** ******
* * *** **** ** * ** * * if (x<61)
* ** * * * **
** * * ** ** * * *** * * *** = FIXED_AMOUNT + (x-20)*1 + 30*0.6 + 20*0.8;
* * * * ** * **** ** ***** *** ** **** *** ** ***** * ****** ****
****** * * *
** * ** * * * * *
* * * ** ***
* * ** ** ****** * * * * **** **** **** ** * = FIXED_AMOUNT + (x-60)*1.2 + 30*0.6 + 20*0.8 + 10*1;
* ** * ** ** * * ** * ** * ***** * *** * * * * * ** ** * ***** **
** * ** * **** **** ***

** ** * * ****** ** 0;

}
answered by (-281 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 0
-----------Re-judge-----------
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(){

    float a,b,c,d,e;

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

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

* * * * ** **** * * ** * * * * * *** ** ** * * * && a>30){
* * * * * ** *** ** * *** * ** * * **** * * * *** *

* *** ***** * * * ** ***** *** * ** **** * && a>50){
** * * ** ** * * * ** * ** *** * * ** * ** * * * ***** **** * **

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










    return 0;



}
answered by (-301 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>
#include <stdlib.h>

int main()
{
* * ** * * * ** **** * * * a;
***** * *** * * *** * **** ** * ** * * * ** *
**** *** ** **** * * * *** ****
* * **** *** * ***** * *** * ** * **** *** * * *** ** * ** * ** ** **
    else if(a<=50)
** * ** * ** ** ****** * * ****** *** * * ***** ** * * ** **** * ** * * *
** * *** *** ** * if(a<=60)
*** ** * * ** * ****** *** *** * **** * ** * **** ****** *** * ** * ***** **
* * ** ** * * * *** * **
**** ** * ** * * * ***** * ** * * **** *** * *** * * ** * *** * ** * *** * * * *
** * ** * * * *** 0;
}
answered by (-258 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!
** * * * ** * **

* * ** ***



int main()

{
*** * * * ** ** ** * total = 0;

*** * ** *** * **** *** ** amount = 0;

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

** * ** ** *** * amount * ** 30 )
*** * ** * * * ****** ** **
* **** ** * ** **** * * * * * *** ** * * ** ***** = amount * 0.6 + 10;
** * *** * ***** *

** * *** *** **** * ** if( amount * * 50 )
*** ** *** ** **** *
**** * ** * ***** * ******** **** *** * * = 10 + 30 * 0.6 + ( amount - 30 ) * 0.8;
**** *** * *** ** * * ****** *

*** * *** ** ** * *** if( amount * *** 60 )
**** *** *** *** * ** *
** ** * *** * *** * ** ** * ** **** = 10 + 30 * 0.6 + 20 * 0.8 + ( amount - 50 );
* * * * * * ***

** ***** * * * ****** * **
* **** ** * * ** * **
* ** ** ** * ** * **** *** * * * * * ** **** ** = 10 + 30 * 0.6 + 20 * 0.8 + 10 * 1 + ( amount - 60 ) * 1.2;
** * ** ** ****** **

** ** * ** ** *** **** * *** ** * *** * * **
* ** *** * ** * ** 0;

}
answered by (-285 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 0
-----------Re-judge-----------
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!
*** * * ** ** * * ***
#define FIXED_AMOUNT 10
int main()
{
* * ** *** * **  x, first_30cb, ** * * * ** next_10cb, add_metercb;
** *** * ** ****** **** ** * &x);
**** * * ** * ** * * (x<31)
* ** ******
** ** *** ********* ** *** ** ** *** ** **** = FIXED_AMOUNT + x*0.6;
** * *** * * * *** ** * ******** ***** * * * * *** * * ** *** *
* *** ** * *** *
** * * ***** * if (x<51)
**** **** ** * * *
* ** * ** ** * * * * * ******* *** * ** *** ** * = FIXED_AMOUNT + (x-30)*0.8 + 30*0.6;
* * ***** * * ** * ** ** * **** ***** * ******** *** **
** * ** ** *
**** ** ** if (x<61)
** * * ** ******
* * ** * **** ** **** ** * *** = FIXED_AMOUNT + (x-20)*1 + 30*0.6 + 20*0.8;
*** * ******* * ******** ***** ** * * * * * ** ** * *
*** **** * *** * **
**** ** * * * *
* **** * *** *****
*** * * * * * ****** * ** * *** ** * * ***** ** = FIXED_AMOUNT + (x-60)*1.2 + 30*0.6 + 20*0.8 + 10*1;
***** ** * * * * **** *** *** * * ** * ** * ** ** * * ** *
*** ***** *** * ** * *

**** ** * *** ***** 0;

}
answered by (-281 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
Case 4: Wrong output
0 like 0 dislike
Hidden content!
*** * * * ** * *

* ** ** ***



int main()

{
* ** * * * * ** ** * total = 0;

*** * * ** * ******* ** * ** * += 10;

* **** * *** * * * amount = 0;

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

** ******** ** * * *** * amount ** 30 )
*** ** * ** ***
* *** ** * ** * * ** ** * * * * **** * * = amount * 0.6 + 10;
* ** ***** * * * ****

* ** ** *** * * * if( amount ** 50 )
* **** ** * * **
* **** * * **** * ** * ** *** ** *** *** * = 10 + 30 * 0.6 + ( amount - 30 ) * 0.8;
* ** ***** * ** ****

* ** ** * ** ** if( amount * * 60 )
* ****** **** * * * * *
*** * ** * * * *** *** * * *** ** *** = 10 + 30 * 0.6 + 20 * 0.8 + ( amount - 50 );
** * ** * * * * **** *

**** * * ** * * ***
** * ** ** ** * *
** * * *** *** * * *** * *** * * **** * * = 10 + 30 * 0.6 + 20 * 0.8 + 10 * 1 + ( amount - 60 ) * 1.2;
* * * ** ** * ** *

*** * ** * ** * ** * * * * *** ** *
* ***** ** * * * ** * ** * 0;

}
answered by (-285 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!
** ****** *** ** ****
#define FIXED_AMOUNT 10
int main()
{
* ***** **** ***** *  x, first_30cb, * ****** * ** * next_10cb, add_metercb;
* * ** ** ** ** * * * **** &x);
** * * * *** * ** (x<31)
** **** ******* ** *
* ** * * ** * * * * ** ** * ** ***** ** * = FIXED_AMOUNT + x*0.6;
**** * * ** * * * * ***** *** ** * * ******* * *
***** * *** * ***
***** **** ** ** * * if (x<51)
*** ** ***** * **
** * ***** * * ** ** * *** ** **** ** = FIXED_AMOUNT + (x-30)*0.8 + 30*0.6;
** ***** ** * * * * ** ** * ** ** *** ****** * * *** ** * * * **
* * *** *** ** ** **
**** * * * * **** * if (x<61)
* ** *** * ****
* ********* * *** ** * * ** * * = FIXED_AMOUNT + (x-20)*1 + 30*0.6 + 20*0.8;
* * **** * * * * * ** * ***** *** * * ***** * * * *** * * *
* * *** * ** *
* * **** ** *
** ** * *** ****
* ** * * **** *** ** * *** * * * ** ** * *** **** = FIXED_AMOUNT + (x-60)*1.2 + 30*0.6 + 20*0.8 + 10*1;
** **** *** * ** *** *** ** * * * ** * ** * **** * ** *** ***** ****
* * * ** * *** * ***

* * ** ** * ***** 0;

}
answered by (-281 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct 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.130.171
©2016-2024

Related questions

3 like 0 dislike
87 answers
[Exercise] Coding (C) - asked Oct 12, 2017 in Chapter 3: Formatted Input/Output by thopd (12.1k points)
ID: 26463 - Available when: Unlimited - Due to: Unlimited
| 6.4k views
3 like 0 dislike
86 answers
[Exercise] Coding (C) - asked Oct 5, 2017 in Chapter 4: Expressions by thopd (12.1k points)
ID: 25730 - Available when: Unlimited - Due to: Unlimited
| 5.7k views
12,783 questions
183,443 answers
172,219 comments
4,824 users