0 like 0 dislike

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 | 217 views

0 like 0 dislike
`Hidden content!#include<stdio.h>int main(void){   * ** **** **** * * * *  c,total;* **** **  *** ***** **   ****  ** *  *** ****   *  *  **  * * *     **    * * * *    * * *****  ***** *       ***  **   *** * *  ** ** * *   **  * ****  **  * * *  * *****   ** *  * ** *** **   ** * ** ****      *  *  *  *** * ** ** *      * *******    *  * *  *    if(c>30 && c<=50)   {* ** *   ** * *   ***       * * **  ***** * **    *   *** *** ** *         * * **    *   ****    * * * * *  ****    ****** * * *    *   ** *   **  ** *** * *   ***  ** ********  **  *****    if(c>50 && c<=60)   {***     ***** * **** * **  *       *   *   ** * ** ** *   *  ***  * *  *  ** ** **  *   ** * ** * *** * *  ** * *   ***********  ** *   **    * *** * * *  *  *  *      *    *   ** * **  **   ** ******   {      **   * **   ***** ** *  **  * *  * * *** ***   *   *** ****  **    *   *** **  *    ** * *  *** ********   ***  ****** * * * * * * ***** *   ** *      ** ** }`
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; ****  *   *  *   *  ******  *    **  ** ***  * *  * * **** **    * ****** *   *   *  *  (a<=30)**** *  *    * ****** *** *  * *    ** %.2f",a*0.6+10);*     *  *  *** ***  **** **** ** (a<=50)**   **  **   **  ** **** **  ****     *****  *   ** *  ***   * **  * *  * **   ***** ** *   ****   *     ***  **  * * * (a<=60) * *   ***  ** ***     **  ** *** **** ** ** * *    *    *   **  **   **  **  *** *    **   *  *  ****  *  *   *  *   (a>60)*   ** ***  *  **  * *** **  ***  ******* * ***   **  * *   *****         ******  ** *  * * *    ** ** *  ***    * **  *  *      * * ****   *   0;}`
0 0
prog.c: In function 'main':
prog.c:7:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'float *' [-Wformat=]
scanf("%d",&a);
^
0 like 0 dislike
`Hidden content!#include <stdio.h>#include <stdlib.h>int main(){*     *** * *    **  **    * a; *  * *** ********* * * ******** ** * **** * **   **      * *** * ** ** * (a<=30)**   *  *  *        * ** * *  *  *** * *** %.2d",a*0.6+10);** ****  *    ** * *  ** *** (a<=50) ** * * **  * **     ******  * **      * ** **   * * ** *** ** *       *******  **** * ******* ** *****    *  *  (a<=60) **  * *  **   * * * *  * ** **  *  **  ***   *** **  * **  * ****  ** **  ****    **    *** *   ***  *  ***  (a>60) * *  ** *  **  * *** *  *  ******  *     **   *   ****  ***  ****  * *       * * **   *   ** ** * ***  *****    *     **** * ********* *   * * *  ** ** 0;}`
0 0
prog.c: In function 'main':
prog.c:10:22: warning: format '%d' expects argument of type 'int', but argument 2 has type 'double' [-Wformat=]
printf("Cost: %.2d",a*0.6+10);
^
prog.c:14:26: warning: format '%d' expects argument of type 'int', but argument 2 has type 'double' [-Wformat=]
printf("Cost: %.2d",18+(a-30)*0.8+10);
^
0 like 0 dislike
`Hidden content!#include ** *  *     * int main(void){** ****  * *  ** **** y, fixed_charge=10;*    *  ** * *  *** ***** *   * ***   ***  * * **  * *  *   *** *** (y<=30){**    *** *  *** *   *  * *****  * * * * **  * *  * *    * *  *  *   **} if (y>30 **  * *****   y<=50) **** *  *** ***     *** ** * *  *     ****   **   ** ***** *     *   * *  **       **** ** *  *  *     ** ***     ** ***** *  * *  ** *** *  *    ** *  *  (y>50 ***  ****   y<=60)   *  ******* * ********* * ***       * ** *  * * *  ******** **** **  * ***  ** *  * *** *   ** * ***   *   * *     }*  ***** **   **     * *  ****     * *   ** (y>60)  ******   *   *    * *** * **    ***  **  * *  ********  **  *  * *** ***      **   **** ** ***   ** *  * ** **   * **    * *   **    ** *return 0;}`
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 * *  * * ** *int main(void){  * * **** ***  * ***  * ** y, fixed_charge=10; ***  *** * *** * *  **  ** **  **** *      * * ** *   **  *    *  (y<=30){    * ***   * ***   ** * *** *  * ****** ** *     * **   **   } if (y>30  *** ** **  y<=50)***   **** *  **** *  * *   *      * *    * ** ***    * *   *  **  **  **     ** ** **   ** ** **  ***   * *   * * **    * ***** ****    ***  *   ***  **  *   *   * (y>50 *****  **  y<=60)** * *  *** * **    ****  ** *   * **** * **   **  *** ** *  * *   ****   *  * *   *    **   ** ** * ***   * *   } **   *  **  *   ****  *** *   ***   * (y>60) ***  * **   *    * *    ** * *  ** ***** * *    *    * *  *  *  *  * *  ****  ****** *   ***    * *   **  ********* **  *      * *   *  **** * ** return 0;}`
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(){int n;float cost;  * **   * ****** *  * **** **if(n>60)*   * * ****     * * **** ** **    *   *   *   * * ** ****** *********** *   *  * *       * * *    *      ***  *    **   ***********   ** *   ****  * *** *** * **   **     ***  ** *** **  * * *    * *** * *  *** *if(n<=30)* ****  *    ** * **  *     * *  ** **** *** **  ***    %.2f",cost);return 0;}`
edited
0 0
prog.c: In function 'main':
prog.c:13:1: error: expected declaration or statement at end of input
return 0;
^~~~~~
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: 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 like 0 dislike
`Hidden content!#include *** *** *** ****int main(){*  * *  *      *      ****  **   * sum,n;******           ****    * ****  **** *  **** *    **     * *  ** *  ****** *** *  * ** *   *  *****    *   * ** ** *   *  *** = 10 + n*0.6;      * * **  *    *     *** *  *  *** *  * ** ** * n <50)    * * **    ** * *****  **** * = 10 + 30*0.6 + * **** *     *  ****  *********   ** *   **  * *  **     *      *   ***  *     * * ** **  **   * = 10 + 30*0.6 + 20*0.8 +  * ** *    * *  *** *  ** **  ******* **  * **   ** * ****     ****   ******   **   * = 10 + 30*0.6 + 20*0.8 + 10*1.0 +  *** ** **    * ** * * *** * **   *  *  * ** *  **   * * ***   * sum);** * *  **   **    *  *     ** * * * 0;}`
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(){ ***  *** *       *** ******** * a,b;* *  ** * ***   **   ** **    ** * *     *** ***       *** *****      **** *  *  * * ****  * *** * *    {  ** * *  *****  ***  *  *** *  **  **** **** ***  ** **  *  *** **   ****  **   ** *  **  *    *    * **** **  ** **  * * *   *   *  ****    * ***  * *   ** *     {  *     * *  ** ***   * *  *  ******** ** **** ***  * *  ** ** * *  * *  * * **  **   * * *** **   * *** * * * *** ***  *  * *****     *** ** *     * * * *****        **  * **  * ** *  * * *     ***    * * ***   *  *     *** ****  * * ** ** **  *  * *****      }***   * ** ***  *  *** *** ***** ** if(a>=60)***   * ***   *     * * ** *** * **** ***** **  *  * ***  *   ** **** * ** * * *   **** * *** **   * * *    } *  * **** * **** * * * * ** ** ****   ** *** *  *      *}`
edited by
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: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
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: 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 * ******    *   int main(){ *** ***     * *  *  *** * ****   n,sum;    ***   **  * **  ** *       *   * **  * **  *  **************** ***  * * * *  ** *  * **  * *     * **  **  *  *  * **** * **** *  * *     *   **   * * **** ***  ***  10+n*0.6;** **   ***** *  * ******  *  *  * ** *  **  * **  if(n>30 && n<=50)    ***  ******  ***** *  *** *   ******  * *         *   * ****   *   **  10+18+(n-30)*0.8; *********      ** ****    *  ***** ***** **** * **    *   if (n>50 && n<=60) **    * ***** **  ** ** **   *    *    ** **   *** ** *    ** * * **   *    * * ** * ** **    * ******* *   **** * *   * ****   *    *** *  * ***  *   *  **    **  *   ****  ** *     * * ******* * *  *   %.2f",sum); *      **        *   * * ** ** ** 0;}`