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

7) [6 pts] Write a MATLAB program which calculates the cost to build circular co

ID: 1766048 • Letter: 7

Question

7) [6 pts] Write a MATLAB program which calculates the cost to build circular cones. Surtace afea cone is given by r and h are radius and height of the cone respectively. If the cost per 1em2 is $10.50 the total cost C for n number of cones is given by C A 10.50 n Perform the following tasks to calculate the total cost C for 10 cones, if the radius is 15.2cm and height is 30.5cm. a) Prompt the user to enter his/her full name b) Prompt the user to enter the radius of the cone c) Prompt the user to enter the height of the cone d) Prompt the user to enter number of cones e) Calculate the total cost C ft) Use fprintf to display the output as shown below run your script the command window output should exactly look like this. Enter your full name as the user name. Your script should be able to display the total cost, number of cones, are user name properly for any user input command window output Enter your full name: Sasanthi Peiris Enter the radius of the cone(cm): 15.2 Enter the height of the cone(cm): 30.5 Enter number of cones: 10 Hi Sasanthi Peiris, The surface area of a cone is 2353.1cm*2 The cost for 10 cones is $247077.52

Explanation / Answer

The code is as below:

name = input('Enter your full name:','s');
r = input('Enter the radius of the cone(cm):');
h = input('Enter the height of the cone(cm):');
n = input('Enter number of cones:');
A = pi*r*(r + sqrt(h^2 + r^2));
C = A*10.50*n;
fprintf('Hi %s.The surface area of a cone is %6.1f cm^2 ',name,A);
fprintf('The cost for %d cones is $%6.2f ',n,C);

Output

Enter your full name:Sasanthi Peris
Enter the radius of the cone(cm):15.2
Enter the height of the cone(cm):30.5
Enter number of cones:10
Hi Sasanthi Peris.The surface area of a cone is 2353.1 cm^2
The cost for 10 cones is $247077.52

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