omputer Engineering Department Laboratory Acti vity Form Course Number ES084 Course Title Computer Programming 1 Topios Covered: Switch and if-else if selection structure Implement a program using (oombine the use of) the if-else if and switoho seleotion structure. Objecti ves: Desoription W rite a program thatwill oaloulate and print out bils for the oity water oompany. The water rates vary depending on whetherthe water s for home use, commeroial use or industrial us e. A code of H/h means home use, a oode of C/o means oommeroial use and a code of /i means industrial us e. The water rates are computed as tollows: 0ode H/h: P250.00 plus PO.002 pergallon used 0ode C/o: P5,000.00 forthe first 4 million gallons and PO.002 foreach additional gallon. P8,000 if us age does not exoeed 4 million gallons, P14,000 if us age is more than 4 million gallons but not more that 10 million gallons and P18000 if us age exoeeds 10 million gallons. oode l/: Your program should prompt the user for the oode and the gallons of water used. Your programshould echo your input data and should print the amount due from the user. Your program should use a switoh statementfor the oode (ohar data type). Use the flo at data type for the gallons. Sample Output it Applicable Z: VCCS121G4U.13302-1\EXER13.EXE pata Code -Induitri Enput dath code Irput number of water Cin gallons) uredi S67007 TOTAL COST IS S000.00 Remarks Filename : EXER2_6.C Lab. InstruotorTeacher:Roel B. Lauron

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

#include<stdio.h>

#include<math.h>

 

int main()

{

                char cod;

                int gal;

                float cost;

                printf("Data Codes:");

                printf(" \n                            H-Home \n                          C-Commercial \n                              I-Industrial ");

                printf("\nInput data code: ");

                scanf("%c", &cod);

                printf("\nInput number of water (in gallons) used: ");

                scanf("%d", &gal);

                if (cod=='H'|| cod=='h')

                {

                                cost = 250+(0.002*gal);

                                printf("\nTOTAL COST IS %.2f", cost);

                }

                else if (cod=='C'||cod=='c')

                {

                                if (gal<=4000000)

                                {

                                printf("\nTOTAL COST IS 5000.00");

                                }

                                else

                                {

                                cost = 5000*((gal-4000000)*0.002);

                                printf ("\nTOTAL COST IS %.2f", cost);

                                }

                }

                else if (cod=='I'||cod=='i')

                {

                                if (gal<=4000000)

                                {

                                                printf("\nTOTAL COST IS 8000.00");

                                }

                               

                                else if (gal>=4000000 && gal<=10000000)            

                                {

                                                printf("\nTOTAL COST IS 14000.00 ");

                                }             

                                else if (gal>10000000)

                                {

                                                printf("\nTOTAL COST IS 18000.00 ");

                                }

                               

                }

                else

                {

                                printf ("\nINVALID DATA CODE");

                }             

}

 

I already have this but i dont know how to use switch

Computer Engineering Department
Laboratory Activity Form
Course Number
ES084
Course Title
Computer Programming 1
Topios Covered:
Switch and if-else if selection structure
Implement a program using (combine the use of) the if-else if and
switcho selection structure.
Objecti ves:
Description
W rite a program that will calculate and print out bils for the city
water company. The water rates vary depending on whetherthe water
is for home use, commercial use or industrial use. A code of H/h means
home use, a code of C/c means commercial use and a code of l/i means
industrial use. The water rates are computed as follows:
code H/h: P250.00 plus PO.002 pergallon used
code C/c: P5,000.00 forthe first 4 million gallons
and PO.002 foreach additionalgallon.
code l/i:
P8,000 if us age does not exceed 4 million gallons,
P14,000 if us age is more than 4 million gallons
but not more that 10 million gallons and
P18000 if us age exceeds 10 million gallons.
Your program should prompt the user for the code and the gallons
of water used. Your programshould echo your input data andshould
print the amount due from the user. Your programshould use a
switch statementfor the code (char data type).
Use the flo at data type for the gallons.
Sample Output if Applicable
a Z:ICCS121G4L13382-1\EXER13.EXE
Data Code EI
04-Home)
C-Commerc 2
-Industral)
Enput data code C
Input number of water Cin gallons) usedi S67887
TOTAL COST IS S000.00
Remarks
Filename : EXER2_6.C
Lab.Instructor/Teacher:Roel B. Lauron
Transcribed Image Text:Computer Engineering Department Laboratory Activity Form Course Number ES084 Course Title Computer Programming 1 Topios Covered: Switch and if-else if selection structure Implement a program using (combine the use of) the if-else if and switcho selection structure. Objecti ves: Description W rite a program that will calculate and print out bils for the city water company. The water rates vary depending on whetherthe water is for home use, commercial use or industrial use. A code of H/h means home use, a code of C/c means commercial use and a code of l/i means industrial use. The water rates are computed as follows: code H/h: P250.00 plus PO.002 pergallon used code C/c: P5,000.00 forthe first 4 million gallons and PO.002 foreach additionalgallon. code l/i: P8,000 if us age does not exceed 4 million gallons, P14,000 if us age is more than 4 million gallons but not more that 10 million gallons and P18000 if us age exceeds 10 million gallons. Your program should prompt the user for the code and the gallons of water used. Your programshould echo your input data andshould print the amount due from the user. Your programshould use a switch statementfor the code (char data type). Use the flo at data type for the gallons. Sample Output if Applicable a Z:ICCS121G4L13382-1\EXER13.EXE Data Code EI 04-Home) C-Commerc 2 -Industral) Enput data code C Input number of water Cin gallons) usedi S67887 TOTAL COST IS S000.00 Remarks Filename : EXER2_6.C Lab.Instructor/Teacher:Roel B. Lauron
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY