Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

7. Write a code to calculate the cost of a shopping trip at Goodill The cost wil

ID: 3900646 • Letter: 7

Question

7. Write a code to calculate the cost of a shopping trip at Goodill The cost will depend upon both the type of item you buy, as well as the weight of your item Your code should ask the user to input what type of item they are buying (housewares, clothes, or books), and also the weight of their purchase. Weight should be input as a vector comprised of lbs & oz. (1st value is the lbs and 2nd is oz. ex: instead of 6.25 lb it is [6,4]) Type of Items Weight 0-5 lbs Weight 5-10 lbs Weight more than 10 Small housewares 0.80/lb $4 $0.75 for each$7.75 $0.60 for additional lb or each additional lb or fraction of a lb above fraction of a lb above 5 lbs 10 lbs Clothing $1.60/lb $8 $0.06 for each 12.8 $0.04 for additional oz or fraction of an oz above 5 lbs each additional oz or fraction of an oz above 10 lbs Books and other heavy objects 0.59/lb $2.95 $0.50 for$5.45 0.40 for each additional pound above 5 lbs each additional lb above 10 lbs To make things easier, you may ask the user to enter 1 for housewares, 2 for clothes, etc, or you can use the menu command.)

Explanation / Answer

clear all;

prompt = "What type of item you are buying?";

str=input(prompt, 's');

prompt ="what is the weight of your purchase?";

w=zeros(2,1);

w=input(prompt);

x = w(1,1)+0.0625*w(1,2);

if(strcmp(str,'Small housewares'))

if(x<=5)

c=0.80*x;

end

if((x>5 )&&(x<=10))

c = 4+0.75*(x-5);

end

if(x>10)

c=7.75+0.60*(x-10);

end

end

if(strcmp(str,'Clothing'))

if(x<=5)

c=1.60*x;

end

if((x>5 )&&(x<=10))

c = 8+0.06*(x-5);

end

if(x>10)

c=12.8+0.04*(x-10);

end

end

if(strcmp(str,'Books and other heavy objects'))

if(x<=5)

c=0.59*x;

end

if((x>5 )&&(x<=10))

c = 2.95+0.50*(x-5);

end

if(x>10)

c=5.45+0.40*(x-10);

end

end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote