10. Compute the perimeter of a cirele (circle _perimeter 2 11.Compute the area o
ID: 3911849 • Letter: 1
Question
10. Compute the perimeter of a cirele (circle _perimeter 2 11.Compute the area of a circle (cirele area 12.Compute the total square feet needed: (square feet-number of tables 3 trapezoid area +2* circle area) 144) 13. Compute the material cost (material cost = Itotal square /eer1-367 14. Compute the shipping cost (shipping cost otal seugre feetl-073 15. Compute the total cost of the order (total cost-material cost + shipping cost) 16. Display a material report, including all of the above indicatod amounts, which is formated in a logical and readable fashion Note(s): Your program should produce output identical (when given the same imputs)) to the sample uns) below, values and format SAMPLE RUN: Welcome to the material ordering system Enter the umber of the tables you want to construct: 10 Enter the length of the base of the right trapezoid in inches 2 Enter the length of the first beight of the right trapezoid in inches: 3 Enter the length of the second height of the right trapezoid in inches: 4 Enter the length of the radius of the cirele in inches: 3 .Your report is ready The oblique side of a trapezoid is 2.236 inches long. The perimeter of a trapezoid is 11.236 inches long. The area of a trapezoid is 7.000 square inches. The perimeter of a cirele is 18.850 inches long The area of a circle is 28.274 square inches. The total square feet The material cost is $2202 The shipping cost is $4.38 The total cost to construct 10 tables is $26.40 needed to coastruct 10 tables is 5.385 Upload your script file (Program02m) to D2L's (Program 02) Dropbox
Explanation / Answer
Code:
disp('Welcome to the material ordering system'); % Welcome Message
% Accepting all reqd values
tables = input('Enter the number of tables you want to construct: ');
base = input('Enter the length of the base of the right trapezoid in inches: ');
ht1 = input('Enter the first height of the right trapezoid in inches: ');
ht2 = input('Enter the second height of the right trapezoid in inches: ');
r = input('Enter the radius of the circle in inches: ');
%Calculations acc to given formulas
trap_oblique = sqrt((base ^ 2) + ((ht1 - ht2)^2));
trap_perimeter = base + ht1 + ht2 + trap_oblique;
trap_area = 0.5 * base * (ht1+ht2);
cir_perimeter = 2 * pi * r;
cir_area = pi * r * r;
total_area = tables * ((3*trap_area) + (2*cir_area))/144;
mat_cost = total_area * 3.67;
ship_cost = total_area * 0.73
total = mat_cost + ship_cost;
%Display Report
disp('********************Your Report Is Ready********************')
disp(sprintf('The oblique side of trapezoid is %.3f inches long.',trap_oblique));
disp(sprintf('The perimeter of trapezoid is %.3f inches long.',trap_perimeter));
disp(sprintf('The area of trapezoid is %.3f inches long.',trap_area));
disp(sprintf('The perimeter of circle is %.3f inches.',cir_perimeter));
disp(sprintf('The area of circle is %.3f square inches.',cir_area));
disp(sprintf('The total square feet needed to construct %d tables is %.3f.',tables,total_area));
disp(sprintf('The material cost is $%.3f.',mat_cost));
disp(sprintf('The shipping cost is $%.3f.',ship_cost));
disp(sprintf('The total cost to construct %d tables is $%.3f.',tables,total));
% There seems to be a calculation error in the given sample run costs.
% sprintf() has a similar syntax as in c and cpp. fprintf() can also be used.
% '%.3f' restricts o/p to 3 decimal places.
Output:
Welcome to the material ordering system
Enter the number of tables you want to construct: 10
Enter the length of the base of the right trapezoid in inches: 2
Enter the first height of the right trapezoid in inches: 3
Enter the second height of the right trapezoid in inches: 4
Enter the radius of the circle in inches: 3
********************Your Report Is Ready********************
The oblique side of trapezoid is 2.236 inches long.
The perimeter of trapezoid is 11.236 inches long.
The area of trapezoid is 7.000 inches long.
The perimeter of circle is 18.850 inches.
The area of circle is 28.274 square inches.
The total square feet needed to construct 10 tables is 5.385.
The material cost is $19.764.
The shipping cost is $3.931.
The total cost to construct 10 tables is $23.695.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.