quiz حل الأسئلة الجامعية manage_search الأرشيف

تم الحل ✓
categoryبرمجة وتطوير البرمجيات schoolبكالوريوس event_available2026-07-13

السؤال

Transcribed Image Text:

Q2) a. Write a Matlab function that calculates the surface area and volume of a cube. The equations to calculate the area and volume are: area= 6 x², volume = x³, where x is the length of the cube. Name the function areavolcube. b. Write a Matlab function that calculates the surface area and volume of a cylinder. The equation to calculate the surface area is: (2 πгh+2лг²), where h is the length of the cylinder and r is its radius. The volume = r² h. Name the function areavolcylinder. www wwwww c. Write a Matlab function that calculates the surface area and volume of a sphere. The equations to calculate the area and volume are: area= 4лг², volume = (4/3) π r³, where r is the radius of the sphere. Name the function areavolsphere. wwwwwwmomm Test your functions areavolcube, areavolcylinder, and areavolshpere with the Test your functions areavolcube, areavolcylinder, and areavolshpere with the following Matlab program This program is available on Folio under the lab assignment. % Program testlab 9 2.m This program calculates the area an volume of cubes, cylinders, and spheres. The program asks the user for the object: cube, cylinder or sphere % Then the program uses the user-defined Matlab functions: areavolcube, % areavolcylinder, and areavolshpere obj = input('Enter the object: K = cube, C = cylinder, S = sphere', 's') switch obj me end case 'K', 'k'} x= input ('Enter the length of the cube, x = '); [area, vol] = areavolcube (x); www fprintf('The area of the cube is: %4.2f \n', area) fprintf('The volume of the cube is: %4.2f \n', vol) case {'C' } case www h = input('Enter the length of the cylinder, h = '); r = input('Enter the radius of the cylinder, r = '); [area, vol] = areavolcylinder (h,r); fprintf('The area of the cylinder is: %4.2f \n', area) fprintf('The volume of the cylinder is: %4.2f \n', vol) 'S', 's'} r = input('Enter the radius of the sphere, r = '); [area, voll = areavolsphere (r); www www. fprintf('The area of the sphere is: %4.2f \n', area) fprintf('The volume of the sphere is: %4.2f \n', vol) otherwise display('Error: Wrong object entered') Use the following values to test the program testlab_9_2.m Cube: x=3 Cylinder: h=5, r=2 Sphere: r=4

check_circle الجواب — حل مفصل خطوة بخطوة

hourglass_top