1.Write a program that will calculate and print out bills for the city water company.The water rates depend on whether the bill is for home use,commercialuse,or industrial use.A code of h means home use,a code of c means commercial use,and a code of
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 17:47:29
1.Write a program that will calculate and print out bills for the city water company.The water rates depend on whether the bill is for home use,commercialuse,or industrial use.A code of h means home use,a code of c means commercial use,and a code of
1.Write a program that will calculate and print out bills for the city water
company.The water rates depend on whether the bill is for home use,commercial
use,or industrial use.A code of h means home use,a code of c means
commercial use,and a code of i means industrial use.Any other code should
be treated as an error.The water rates are computed as follows:
Code h:$5.00 plus #0.0005 per gallon used.
Code c:$1000 for the first 4 million gallons used,and $.00025 for each
additional gallon.
Code i:$1000 if usage does not exceed 4 million gallons; $2000 if usage is
more than 4 million gallons,but does not exceed 10 million gallons; $3000
if usage exceeds 10 million gallons.
Your program should prompt the user to enter the code (type char),and the
gallons of water used (type float).Your program should then print the amount
due from the user.
---------------
Test Data:
Code:h
Usage:10000
Amount Due:$10
Code:c
Usage:5000000
Amount Due:$1250
Code:i
Usage:5000000
Amount Due:$2000
2 Write a program that takes in an alphabet character input from the user (you need
to do only lower case),and prints out the corresponding number on your telephone
handset.For example,if the input is a,then the number is 2.if the input is p,the
number is 7.If the input is not one of the characters in the alphabet,the number
that is printed is -1.Implement 2 versions of the program,one using switch statement
and one using if statements.
----------------
Test Data:
Enter the character:a
Corresponding number on the telephone :2
1.Write a program that will calculate and print out bills for the city water company.The water rates depend on whether the bill is for home use,commercialuse,or industrial use.A code of h means home use,a code of c means commercial use,and a code of
第一个:
#include
using namespace std;
int main(){
char code;
int usage;
double payment;
coutcode;
switch(code){
case 'h':coutusage;cout