1 answer

The price for renting a car at a car rental company is according to the following...

Question:

The price for renting a car at a car rental company is according to the following schedule: Sedan SUV Duration of rent Daily Free Cost of Daily Free Cost of rate miles Additional rate miles Additional (per day) mile (per day) mile 1-6 days $79 80 $0.69 $84 80 $0.74 7-29 days $69 100 $0.59 $74 100 $0.64. 30 or more days $59 120 S049 $64 120 $0.54 Write a MATLAB program in a script file that calculates the cost of renting a car based on the shown price schedule. The program must ask the user to enter the type of car (Sedan or SUV), the number of days, and the number of miles driven. The program then displays the cost (rounded to cents) for the rent in a sentence that reads: The cost of the rent is xxx where XXX is the cost value in Run the program three times for the following cases: (a) Sedan, 10 days, 769 miles. (b) SUV, 32 days, 4,056 miles. (c) Sedan, 3 days, 511 miles. Hint: Use a switch-case structure for the type of the car (Sedan SUV) with nested alternative if structure for the number of days and miles. Use printf 0 to display the text and data. The data should be displayed in f format with two decimal digits.
The price for renting a car at a car rental company is according to the following schedule: Write a MATLAB program in a script file that calculates the cost of renting a car based on the shown price schedule. The program must ask the user to enter the type of car (Sedan or SUV), the number of days, and the number of miles driven. The program then displays the cost (rounded to cents) for the rent in a sentence that reads: "The cost of the rent is XXX $." where XXX is the cost value in $. Run the program three times for the following cases: Sedan, 10 days, 769 miles. SUV, 32 days, 4, 056 miles. Sedan, 3 days, 511 miles. Use fprintf () to display the text and data. The data should be displayed in f format with two decimal digits.

Answers

car_type = input('Enter car type: ', 's'); num_days = input('Enter number of days: '); num_miles = input('Enter miles driven: '); total_cost = 0;  switch(car_type)     case 'Sedan'         if num_days <= 6             total_cost = 79;             if num_miles > (num_days * 80)                 total_cost = total_cost + (num_days - 80) * 0.69;             end         elseif num_days <= 29             total_cost = 69;             if num_miles > (num_days * 100)                 total_cost = total_cost + (num_days - 100) * 0.59;             end         else             total_cost = 59;             if num_miles > (num_days * 120)                 total_cost = total_cost + (num_days - 120) * 0.49;             end         end     case 'SUV'       if num_days <= 6           total_cost = 84;           if num_miles > (num_days * 80)               total_cost = total_cost + (num_days - 80) * 0.74;           end       elseif num_days <= 29           total_cost = 74;           if num_miles > (num_days * 100)               total_cost = total_cost + (num_days - 100) * 0.64;           end       else           total_cost = 64;           if num_miles > (num_days * 120)               total_cost = total_cost + (num_days - 120) * 0.54;           end       end     otherwise       fprintf('Invalid Input\n');       quit end  fprintf('The rent costs $%0.2f\n', cost);
.

Similar Solved Questions

1 answer
A Cournot oligopoly has four firms in the industry. The market price elasticity of demand is...
A Cournot oligopoly has four firms in the industry. The market price elasticity of demand is -2.5 and the marginal cost of production is $200. What is the profit- maximizing price, rounded to the nearest dollar? $500 $222 $354 More information is needed to answer this question. $208...
1 answer
Explain why the derivative of g(x) = 1/1+t^2 dt is NOT g'(x) = 1 / 1+x...
Explain why the derivative of g(x) = 1/1+t^2 dt is NOT g'(x) = 1 / 1+x -cos^2 x using FTC1 and the chain tan x 1  t 2 1  x rule. Find the correct g’(x). Н tan...
1 answer
Mechanical engineering analysis help, please show all work, thanks. Problem 3. Show that the solution of...
mechanical engineering analysis help, please show all work, thanks. Problem 3. Show that the solution of the partial differential equation (Laplace equation), Wxx(x,y) + wyy(x, y) = 0, with the four boundary conditions: w(x,0) = 0, w(x,1) = 0, w(0,y) = 0 and w(1, y) = 24 sin ny, can be obtained as w...
1 answer
Function X AX Where X abx? - abot toa-d, where Determine Wheller linear transformation. T: R2...
Function X AX Where X abx? - abot toa-d, where Determine Wheller linear transformation. T: R2 T: Main Mmm T (A) = IS Fixed matric R. T (A)=lxal, where to Mon is fixed matrisc IR T (x, y) = (x-y, Ory) A=fa b d T: P₂ - Mand T Caxc² + box + = [a-b be a-c T: P - P. , T (ax² + bx tc) = ab...
1 answer
If the donut industry is perfectly competitive and is in long-run equilibrium, then the price of...
If the donut industry is perfectly competitive and is in long-run equilibrium, then the price of a donut Question 20 options: A) equals long-run average cost. B) is greater than marginal cost. C) is greater than long-run average cost. D) is greater th...
1 answer
Is1 15 mA R. 1ΚΩ In the circuit shown, use KCL, KVL, and Ohm's Law to...
Is1 15 mA R. 1ΚΩ In the circuit shown, use KCL, KVL, and Ohm's Law to find the two resistor currents R1 R2 K. S2 25 V 0.5 kΩ 5 mA iR2 1R2 =...
1 answer
1. a) 3 incompletely linked genes are found in the order A-B-C. You would expect the...
1. a) 3 incompletely linked genes are found in the order A-B-C. You would expect the recombination frequency to be lowest between a. A and B    b. A and C         c. B and C        d. Unable to compute   &...
1 answer
Problem 3a: An RR robot has two links of length 0.75 m and 1.0 m, respectively....
Problem 3a: An RR robot has two links of length 0.75 m and 1.0 m, respectively. Assuming that the global coordinate system is defined at Ji, determine the following: (a) The coordinates of the end-effector point if the joint rotations are 35 degrees at both joints as shown in the handout. (b) Joint ...
1 answer
A study was made by a publishing company on how advertising costs for the company correlated...
A study was made by a publishing company on how advertising costs for the company correlated with sales. Find the equation of the regression line to predict sales from advertising costs. Estimate the weekly sales when advertising costs are 35TL. Advertising costs Sales 50 530 35 ...
1 answer
Q. 05: The Treadwater Bank wants to raise $1.1 million using three-month commercial paper. The net...
Q. 05: The Treadwater Bank wants to raise $1.1 million using three-month commercial paper. The net proceeds to the bank will be $1,084,600. What is the effective annual rate of this financing for Treadwater? Solution: Q. 06: The Needy Corporation borrowed $14,000 from Bank Ease. According to the ter...
1 answer
How do find the derivative of #y = (sec)^2 x + (tan)^2 x#?
How do find the derivative of #y = (sec)^2 x + (tan)^2 x#?...
1 answer
A manometer is needed to measure a pressure difference of +/- 50 millibars. If you make...
A manometer is needed to measure a pressure difference of +/- 50 millibars. If you make the device using water, how large will it have to be? How is it different if you fill the device with mercury?...
1 answer
Price and cost (dollars per toy) The graph shows the short-run cost curves of a toy...
Price and cost (dollars per toy) The graph shows the short-run cost curves of a toy producer. Assume the toy producer is in a perfectly competitive market. If the market price of a toy is $11, then O A. The firm will break even. OB. The firm will lose an amount greater than its fixed costs. O C . Th...
1 answer
Q5. Faraday's law says that a) an emf is induced in a closed loop if the...
Q5. Faraday's law says that a) an emf is induced in a closed loop if the magnetic flux through the loop does not change (ε = lng) = 0) b) an emf is induced in a closed loop if the magnetic flux through the loop changes ΔΦ E = -1 At c) an emf is induced in a closed loop only if ...
1 answer
Help: A sample is a mixture of the salts and silver nitrate, copper (II) chloride, and iron...
A sample is a mixture of the salts and silver nitrate, copper (II) chloride, and iron (III) chloride. When a 1.000 g sample of the mixture is dissolved in water andreacted with excess silver nitrate, 1.7809 g of precipitate forms. When a separate 1.000g sample of the mixture is treated with a reduci...
1 answer
3. Let D be the region in the first quadrant lying inside the disk x2 +y2...
3. Let D be the region in the first quadrant lying inside the disk x2 +y2 < 4 and under the line y-v 3 x. Consider the double integral I-( y) dA. a. Write I as an iterated integral in the order drdy. b. Write I as an iterated integral in the order dydx c. Write I as an iterated integral in polar ...
1 answer
2. Jason Smith wes your company 51,000. Prepare the entry using the direct write-off method) to...
2. Jason Smith wes your company 51,000. Prepare the entry using the direct write-off method) to write off the balance that he owes you. Then, assume that he actually does pay you the $1.000, pepare the necessary entries to reinstate the receivable and record the receipt of cash...