Question

In: Computer Science

The electricity accounts of residents in a very small rural community are calculated as follows: a....

The electricity accounts of residents in a very small rural community are calculated as follows: a. if 500 units or less are used the cost is 2 cents per unit; b. if more than 500, but not more than 1000 units are used, the cost is $10 for the first 500 units, and then 5 cents for every unit in excess of 500; c. if more than 1000 units are used, the cost is $35 for the first 1000 units plus 10 cents for every unit in excess of 1000; d. in addition, a basic service fee of $5 is charged, no matter how much electricity is used. The five residents use the following amounts (units) of electricity in a certain month: 200, 500, 700, 1000, and 1500. Write a program which uses logical vectors 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. (Answers: $9, $15, $25, $40, $90)

Solutions

Expert Solution

::Matlab Code::

Using Logical vectors to calculate payment instead of else-if ladders, the code looks like this-

% logical vectors 

unit = [200 500 700 1000 1500]; 
bill = 10 * (unit > 500) + 25 * (unit > 1000) + 5;
bill = bill + 0.02 * (unit <= 500) .* unit;
bill = bill + 0.05 * (unit > 500 & unit <= 1000) .* (unit - 500);
bill = bill + 0.1 * (unit > 1000) .* (unit - 1000);

fprintf("\t Units \t Charge(in $) \n");
disp( [unit' bill'] );

Output of above program:

Refer to the screenshot below for better understaning of code indentaion -


Related Solutions

2.   A small community currently taxes residents to provide monthly community concerts. Voter A currently pays...
2.   A small community currently taxes residents to provide monthly community concerts. Voter A currently pays a tax per concert equal to $50 per month. This voter receives a marginal benefit of $75 at the current political equilibrium number of concerts per month. Voter A: a.    is the median voter. b.   would be made better off if the number of monthly concerts were increased. c.    would be made worse off if the number of monthly concerts were increased. d.   has...
A politician wants to cut a rural health initiative because the mortality rate of rural residents...
A politician wants to cut a rural health initiative because the mortality rate of rural residents (13.75 per 1000) is lower than the mortality rate among city dwellers (20.77 per 1000). Observe the age-specific rates for each population and comment if he is justified in cutting spending based on crude rates. *Age-specific rates: An age-specific rate is calculated in the same manner as the crude rate except that both the number of events and the mid-year population are restricted to...
Managing Change Jennifer Kowal, a family nurse practitioner, moves to a small rural community in Michigan....
Managing Change Jennifer Kowal, a family nurse practitioner, moves to a small rural community in Michigan. There is no primary health care office within a 50-mile radius. She decides that she will open a community health center and provide primary care services. Nurse Kowal has never managed or owned a business. She has negotiated a collaborative agreement with a family practice physician in a major urban area. Nurse Kowal begins to review the literature on best practices in primary care...
2. Economists observed the only 5 residents of a very small economy and estimated each one’s...
2. Economists observed the only 5 residents of a very small economy and estimated each one’s consumer spending at various levels of current disposable income. The accompanying table shows each resident’s consumer spending at three income levels. individual Consumer Individual Current Disposable Income $0 $20,000 $40,000 Andre 1,000 15,000 29,000 Bob 2,500 12,500 22,500 Casey 2,000 20,000 38,000 Dianne 5,000 17,000 29,000 Elena 4,000 19,000 34,000 a) What is each resident’s consumption function? What is the MPC for each resident?...
Literature review on Health Care in the Rural Community
Literature review on Health Care in the Rural Community
Question: Stephanie runs a small retail business in a poor rural community.  She has 4 employees, 2...
Question: Stephanie runs a small retail business in a poor rural community.  She has 4 employees, 2 of them part time, all of them older adults who have grown up in the area.  She has had only modest success so she has never been able to afford to provide health insurance for her employees. None of them have private insurance or Medicaid -- nor do they have primary care doctors. They rely on a small local urgent care center or the emergency...
It has been suggested that residents in the rural areas of the South have a different...
It has been suggested that residents in the rural areas of the South have a different life-span than in the North. In a random sample of 50 residents of the rural South, the mean life span was 75.9 with a sample standard deviation of 9.8. A random sample of 75 residents of the North, the mean life span was 82.4 with a sample standard deviation of 6.1. Is the sample evidence strong enough to claim that those in the South...
In a large city, the population proportion of residents favoring an increase in electricity price is...
In a large city, the population proportion of residents favoring an increase in electricity price is P = 0.35. A random sample of n = 144. Use p to denote the sample proportion of residents favoring the increase in electricity price. 1. The mean (or expected value) of the sample proportion p is 2. The standard deviation of the sample proportion P is closest to 3. The probability that the sample proportion P is less than or equal to 0.40...
In a small, rather isolated community of mostly recent refugee immigrants, the eco-nomic situation is very...
In a small, rather isolated community of mostly recent refugee immigrants, the eco-nomic situation is very depressed and a large fraction of the adult population findsitself unemployed. A young, Columbia-trained economist then suggests that givingmoney transfers to refugees might be a great idea. She explains: “I have studied thesepeople’s consumption behavior and they seem to consume a large part of any incomethey receive, maybe even 90%. So I think overall income in this community might riseby around $5 for each...
how does social capital enhance wellbeing in a rural community
how does social capital enhance wellbeing in a rural community
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT