Question
MATLAB engineering programming language Challenge Problem 8 Your task is to calculate part of the users utility bill by completing the following steps. 1. Use
MATLAB engineering programming language
Challenge Problem 8
Your task is to calculate part of the users utility bill by completing the following steps. 1. Use a menu to ask the user whether they want to calculate a water bill or electricity bill. 2. Prompt the user to enter how many units they estimate they use (kilogallons for water bill, kilowatt hours for electricity bill). 3. Call a subfunction to calculate the total cost to the user for this portion of their bill. The subfunctions should be called electricBill and waterBill, and each should have one input (the number of units used) and one output (the cost). Define your functions sequentially. You will need to know the following price structure: For electricity, the user is charged a flat fee of $20.50, plus 8.5 cents for each kilowatt-hour (kWh), and the user is charged an additional 1.6 cents for each kWh over 800. For water, the user is charged a flat fee of $27.50 and $1.60 per kgal for the first 8 kgals, $2.70 per kgal for the next 22 kgals (up to 30 kgals total), $4.38 per kgal for any kgals over 30 kgals. 4. After the subfunction calculates the total amount, send the results to the command window in a readable sentence, like Your electricity bill will be $50.00 or Your water bill will be $25.98. 5. Be sure to test your program a few times. Here are some sample inputs and outputs: Electricity: Using 700 kWh will cost $80.00. Using 1000 kWh will cost $108.70. Water: Using 11 kgals will cost $48.40. Using 25 kgals will cost $86.20. Using 40 kgals will cost $143.50. |
Grading Criteria. To achieve Meets Expectations for this Challenge Problem, the file should: Follow the layout described above (menu -> prompt -> subfunction -> display results). Produce (nearly) correct results for a variety of inputs. To achieve Exceeds Expectations for this Challenge Problem, the file should: Follow the layout described above, using the subfunction names as indicated. Produce correct results for a variety of inputs, with nicely formatted outputs. Use elegant code that is simple and clear. |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started