Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solve in MATLAB 3. Electric consumption The electricity accounts of residents in a very small rural community are calculated as follows if 500 units or

Solve in MATLAB

image text in transcribed

3. Electric consumption The electricity accounts of residents in a very small rural community are calculated as follows if 500 units or less are used, the cost is 2 cents per unit; if more than 500, but not more than 1000 units are used, the cost is $10 for the first 500 if more than 1000 units are used, the cost is $35 for the first 1000 units plus 10 cents for in addition, a basic service fee of $5 is charged, no matter how much electricity is used units, and then 5 cents for every unit in excess of 500; every unit in excess of 1000; The five residents use the following amounts (units) of electricity in a certain month: 200, 500, 700, 1000 and 1500. Write a program that uses a for loop to calculate how much they must pay. Display the results in two columns: one for the electricity used in each case, and one for amount owed. Test Case: e = [200 500 700 1000 1500]; ecost = kwcost( e ) ; TT-table (e ' ,ecost' , 'VariableNames' ' { ' Usage-kWh' , ' Cost-USD')) ; disp (TT) Result: Usaqe kWh Cost USD 200 500 700 1000 1500 15 25 40 90 4. Fibonacci numbers Fibonacci numbers were originally developed to model the idealized population growth of rabbits. Since then, they have been ound to be significant in any naturally occurring phenomenon. The Fibonacci numbers can be generated using a recursive formula. The recursive step contains two recursive calls and there are two base casesi.e. two cases that cause the recursion to stop). Write a function for computing the n-th Fibonacci number F(n) = F(n1) F(n2) otherwise By recursion, we mean that your function will call your function from within itself. Test Cases: >> myFib(10) ans- >> myFib(25) ansE 75025

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions