Question: HW 5 Problem 1 (35 points): water bill calculation Fixed Cost: Residential - fixed cost Government - fixed cost Business - fixed cost User


HW 5 Problem 1 (35 points): water bill calculation Fixed Cost: Residential - fixed cost Government - fixed cost Business - fixed cost User Residential Government Business Tax rate is 8.7% From the table above, Ex 1: residential, 450 cubic feet Water Usage (w) In cubic feet (cf) Ex 2: business, 1250 cubic feet For the first 400 cf, w 400 For the next 300 cf, 400 < w 700 For additional cf above 700 w > 700 $13.50 $ 3.75 $17.25 Cost per cubic foot total cost before tax = 17.25 +0.0553*1250 = 86.375 total cost after tax = (1+8.7/100)* 86.375=93.89 0.04 0.062 0.12 total cost before tax = 13.5+ (0.04*400) + 0.062*(450-400) = 32.6 total cost after tax = (1+8.7/100)* 32.6= 35.44 0.035 0.0553 Write a C program that read from the text file called "usage_data.txt" (on zyBooks, download it). for each line (consisting of a user type and water usage in cubic feet) in the given text file, find the total cost (including tax) and display the table of information (including the calculated cost) as shown in the sample code execution. Your C program must use the following user defined function: double water_billcalculation (char user_type, int water_use); //the function accepts user type and water usage in cubic feet and returns the cost with tax Note: To read one line from the text file, the statement below can be used. fscanf(your_file_pointername, "%c%d ",&var_youuseforUserType, &var_youusefor_cubicfeet); Observe that there is a space after %d - used to tell fscanf to ignore a newline character at the end of that line. 1 Sample code execution: Given part of "usage_data.txt (more test cases are given in the text file) r 120 g 5000 B 1250 M 50 R 450 G 1750 b 274 A 10 If your program works correctly, below is part of what your code should display Type Water usage Cost including tax($) r 120 19.89 g 5000 194.30 B 1250 93.89 M R G A Type is not found 450 1750 274 Type is not found 35.44 70.66 35.22 Note: The user type can now be either lowercase or UPPERcase. If the type is not Residential (R/r), Business (B/b) or Government (G/g), it should display "Type is not found".
Step by Step Solution
3.37 Rating (150 Votes )
There are 3 Steps involved in it
C Program include stdio h include stdlib h Function prototype double waterbillcalcul... View full answer
Get step-by-step solutions from verified subject matter experts
