For questions 1, 2, and 3, walk through each question by hand, then use the “disp”...

Free

70.2K

Verified Solution

Question

Mechanical Engineering


For questions 1, 2, and 3, walk through each question by hand, thenuse the “disp” command in your MATLAB script to display your answerto the screen.
1. What is the final value of x? x = 10; if round(x/5) == x/5 x = 2* x + 4; elseif x == 10 x = 4 * x; else x = 0; end
2. What is the final value of x? x = 10; if round(x/3) == x/3 x = 2* x + 4; elseif x == 10 x = 4 * x; else x = 0; end
3. What is the final value of x? x = 9; if round(x/4) == x/4 x = 2* x + 4; elseif x == 4 x = 4 * x; else x = 0; end
4. Write a MATLAB script that calculates the total cost for GiantSlinkys: • Ask the user to input the quantity of Giant Slinkys theywish to have shipped. • Make sure the user's input is a positiveinteger. • 10 or fewer Giant Slinkys cost $21.99 each. • 11 to 50Giant Slinkys are $19.99 each • 51 to 100 Giant Slinkys are $17.99each • More than 100 Giant Slinkys cost $15 each. • Sales tax is9.5% • Shipping is $10 for each group of 10 Giant Slinkys. Forexample: ◦ Shipping for 1 Giant Slinky is $10; Shipping for 8 isalso $0; Shipping for 10: $10. ◦ Shipping for 11 Giant Slinkys is$20; Shipping for 15, also $20; Shipping for 20: $20. • Shipping isfree for orders of 50 or more Giant Slinkys

Answer & Explanation Solved by verified expert
4.2 Ratings (685 Votes)

1.

clear all;close all;clc;commandwindow;

x=10;

if round(x/5)==x/5

x=(2*x)+4;

else

if x==10

x=4*x;

else

x=0;

end

end

disp(x);

2.

x=10;

if round(x/3)==x/3

x=(2*x)+4;

else

if x==10

x=4*x;

else

x=0;

end

end

disp(x);

3.

x=10;

if round(x/4)==x/4

x=(2*x)+4;

else

if x==10

x=4*x;

else

x=0;

end

end

disp(x);

4.

quantity=input('enter the number of giant slinkys you wish to ship');

if quantity<0

display('Please enter a positive value');

else

flag=0;

if quantity<=10

cost=quantity*21.99;

end

if quantity>=11 && quantity<=50

cost=quantity*19.99;

end

if quantity>=51 && quantity<=100

cost=quantity*17.99;

end

if quantity>100

cost=quantity*15;

end

if quantity>=50

shipping_cost=0;

else

quantity=ceil(quantity/10);

shipping_cost=quantity*10;

end

cost=cost+((cost*9.5)/100)+shipping_cost;   

display('total cost is:')

display(cost);

end


Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students