1 like 1 dislike
13.1k 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: 32351 - Available when: 2017-11-15 14:10 - Due to: Unlimited
| 13.1k views

59 Answers

0 like 0 dislike
Hidden content!
#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);
** * ***** ** ** * * ***** ** * * * ******** ** ** **** * %.2f",((a-30)*0.8)+b+c);
* * * * ** ** * * * * ** *** * * ****

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

** ** ***** * ** * * 0;
}
answered
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>

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


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

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

*** * *** * *** * *** ** * 0;
}
answered
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!
answered by (-32 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 1
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main(void)
{
* * *** * * **** * total;
***** *** ***** * ** * m;
* ***** * ** *** ** * * *** *** * * *** *
*** *** *** * * ** * * ** * *
*** **** ** ***** ** *
** **** ** *** **** * *** * **** *** ** * * * ** * * ** * ***
* *** * * ** ** *** ** * * * **** *** ******* ***** * %.2f",total);
** *** ** ** ** * ** * * ***
* ** * ** ** * * ** * * *** * * && m<50)
    {
*** * * **** *** * * * * *** * ** *** **** * ** ***
***** ** * * *** * ** * ***** ** * * ** ***** *** ** %.2f",total);
    }
** * * ** ** ** * ** ** * && m<60)
*** ***** ** **** *** *
* * ** ** * *** * * *** **** ** * * *** * * *** ** * ** ******
* ** ***** * * ** ** * *** **** * * * * ** ** %.2f",total);
* * ** ** * **** ** ** ** *
*** ***** * *** *** * ** * *
** * ***** * * ** *
* *** * ****** ***** * * ***** * ** **** *** *** *** * * *
**** * * ** ** * ** ***** * * * * **** ** ** * * ** * %.2f",total);
    }
*** *** * *** * *** *** ****** 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 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

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


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


    if (a<=50)
* * ** * * * *** ** *** * * ** ****** **** ** * * * * * * ** ** * * *
* * **** * * *** ** * ****** * * * * (a>50);
**** * ***** * * * *** * * ****** ** * * * ** * *** * ***

    if (a<=60)
******** * *** * ** ** *** *** ** * ***** **** * ** * * ** ***** **** * * ** * *
* * * * * * ** ****** * ** **** ****** * ***** (a>60);
* *** **** * ** * ** ** *** ** **** *** ** * *** ** *** *** ***** * ***** ** * *

*** * **** * * ** ***** 0;
}
answered
0 0
prog.c: In function 'main':
prog.c:23:20: warning: format '%f' expects argument of type 'double', but argument 2 has type 'int' [-Wformat=]
         printf("%.2f",((a-50)*1)+b+c+d);
                    ^
prog.c:26:20: warning: format '%f' expects argument of type 'double', but argument 2 has type 'int' [-Wformat=]
         printf("%.2f",((a-50)*1)+b+c+d);
                    ^
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

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


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


    if (a<=50)
*** ** **** * * * * * *** **** **** * ** * * * ******** **
* *** * * * * * ** * **** **** * * ** * **** * **** (a>50);
* ****** * * ** **** *** ** ** * * ** *** ** ** ** ** * *** ** **

    if (a<=60)
** * ** * * **** **** ** **** * ******** * ** * *** ** ** ** *
*** *** ** * * ** * * * * * * ** (a>60);
* * *** * *** ****** * ** *** ** ** * * * *** ** ** * * ******** * * ** **** * *

* * * * * * 0;
}
answered
0 0
prog.c: In function 'main':
prog.c:23:20: warning: format '%f' expects argument of type 'double', but argument 2 has type 'int' [-Wformat=]
         printf("%.2f",((a-50)*1)+b+c+d);
                    ^
prog.c:26:20: warning: format '%f' expects argument of type 'double', but argument 2 has type 'int' [-Wformat=]
         printf("%.2f",((a-50)*1)+b+c+d);
                    ^
0 like 0 dislike
Hidden content!
#include * ** * ***

int main()
{
* * ** * *** use;
****** ***** ** *** * * * ** ** *** ***** * ** netamt;
*** * ** **** ** * * ** * * ****
** **** *** * * ** ** ** * <= 30)
* ** * * ** * * * * * = use * 0.60;
* *** * * ***** * ****
else if(use <= 50){
sec2 = 18 + ((use-30) * 0.80);
** * **** * ** *
**** ******* *** * * * * ***** if(use <= 60)
**** * ** * **** *
* ** * * ** **** * * *** * **** ** ** * = 38 + ((use-50) * 1.00);
*** * *** * * *** * * *** *
* ** ** * * * * * * if (use ** *
* * * * * ********
** * ** * * * ****** ** ************ * *** * * ** = * * * * ***
* * * ** * *
netamt = ** ** * * ***
** * **** * * * * ** * ** * netamt);

*** * * *** * * *** * ** * 0;
}
answered by (323 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 ** **

int main()
{

* * * ** *** water_c;
* * nt=0;
** **** nt1=0;
  int nt2=0;
*** * ** * * amt=0;
*** * * *** * amt1=0;
** ** ** * **** at=0;
* ** * * * * * total=0;


** **** * ******** ***** * * &water_c);

  if (water_c < 30)
  {
* ** ** * ** * * ** * *** * * *** + 10);
  }

****** * *** ** if *** * * *** * *
  {
***** ** ** * ** * * ** *** ***** ** *****
** ** * * * ** ***** ** ** ** * ** * *

* **** * * * **** ** * ** * ** ** > 20)
** * **** ** ** * * **
* * * *** * * ** * * *** ***** ** * *** * ** *** * ** **** * * * **** *** ** * * * *
** * *** ** ** ** * ** *** * ** *** * * * * * * ** *** * * ***** + amt1 + 10;
* *** ** * **** ** *** ****
* ***** ** * *** * * ** * *
* *** * * * * ******** * * ***
* * ** * * * ** * ** * * * **** ******* * * ** * * * ** * *** *
** * * ** * *** * * ** * **** *** * ** * ***** **** * ** **** * * + amt1 + 10;
** **** * ** * *** * *** * * ** *** ** *
* * * * ** * ** *
  }

* * * * if (water_c>60)
  {
* * * * ******** ***** *** *** * * ***** * ** * *
***** ** * * *** ** ** * * * * * * * ** * ** * ** * ** ** **
  }

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

* ** ** **** * ***** * * **** * * ** ** 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 * * ***

int main()
{

* * * ** * * * water_c;
*** ** ** nt=0;
** ** * * nt1=0;
*** **** * * * nt2=0;
******** * * ** amt=0;
** * *** * * amt1=0;
*** * * * *** ** at=0;
* * * ** * * * total=0;


* *** * *** * * * ** * * * &water_c);

  if (water_c < 30)
  {
* ** **** ** * * * * **** * *** * ** + 10);
  }

* * * * ** if ** **** * * ***** ** * ** **
  {
** * **** * * * ***** * * *** *** ***
* * *** ** * * ** * * ***** ***

** ** ****** *** ** ****** * > 20)
* * * ********** *** * ** ****
* ** ***** ** * *** ** * ** * ** *** ** * *** ** *** *** ** **** **** * * **
* ** * * ** * * **** **** * * * * * ** **** * ** * * ** * + amt1 + 10;
*** ****** *** ** * *** ***
* * ** ** ** * * *** *** * ** ** ** *** *
* * *** * ** * * ** ** *** ** *** * * *
*** *** * * * ** *** * *** * ** * *** * ** ** * * * **** * * **
* ****** ** * ******** ** ** * *** * * ** *** * * ** * ** ** ** ** + amt1 + 10;
** *** * ** **** * ** * * * * ** ***
******** ** * * ** * + amt1 + 10;
  }

* ** *** * if (water_c > 60)
  {
** * * * * **** ** * * * ** * * * * ** * * * * * - 60;
** * ** ** ***** ** * * ** ****** * * ** ** *** * *
  }

*** * ****** * ** * * * ****** * * ** * total);

*** **** * * **** ** * * * ** * ***** *** * ** * * 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()
{
** * ** * * ******* * * ** a,f;
*** * * * * * ** ** * ** * ** ** * * *
* * ** ** * ** *** ** * *
    {
*** ***** * *** * ** ** * *** * * ***** *
* * *** * * * * *
* * *** *** * * ** ** * * * *** * * *
    {
** * ****** ** ** ** * * ** * * * ** * ** * * * *
* ** ** ** *
* * *** * * ** *** * *** * * **** * * ** **** * **
* * ** ** * * * * * *** *
*** * ** * ** **** *** * **** ** ** *** ** * * * *** * *
    }
* **** * ** * ** * *** if(a>60)
* * *** ** * ** * ** * *
* * ** ** * ** ** * * * **** *** * *** **** * * * **
    }
* *** * ** * ** **** * * *** * ** * *
}
95/100 answered by (-255 points)
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.176.65
©2016-2025

Related questions

0 like 0 dislike
19 answers
[Exam] asked Dec 9, 2017 in Midterm by thopd (12.1k points)
ID: 36750 - Available when: 2017-11-15 14:10 - Due to: Unlimited
| 5.5k 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
| 4.9k 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
| 12k views
12,783 questions
183,442 answers
172,219 comments
4,824 users