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

Each student is to complete the following problems individually and submit solut

ID: 3800730 • Letter: E

Question

Each student is to complete the following problems individually and submit solutions before class begins on the due date. Complete your solutions to the problems below in a single script. Put your name at the top of the script using a comment (%), and separate each question with a comment including the question number. Include a semicolon at the end of each line to prevent printing in the Command Window. Run the completed script in the Command Window. Print and submit both your script and your Command Window. Input, Calculations, and Display a. Set the variable x equal to a user-entered number using input. b. Calculate x^2 and x^0.5, assigning each to a new variable name (e.g. x_ squared). c. Use fprintf to display x, x^2, and x^0.5, using descriptive text and the values. Calculating surface area of a cylinder Ask the user to enter the radius (in cm) of a cylinder using input to assign the value to the variable R. b. Ask the user to enter the height of a cylinder (in cm) using input, and assign this value to the variable H. c. Using the user-entered values of the radius and height, calculate the surface area of the cylinder, and assign it to the variable A. d. Use fprintf to display the user-entered radius and height of the cylinder, along with the calculated surface area. Include units and descriptive text. h. Run your script with a radius of 3 cm and a height of 5.2 cm.

Explanation / Answer

%Q 1) MatLab Script:-

prompt='Enter a number: ';
x=input(prompt);
x_square=x^2;
x_squareroot=x^0.5;
fprintf('value of x is %d ',x);
fprintf('value of x^2 is %d ',x_square);
fprintf('value of x^0.5 is %d ',x_squareroot);


%Q 2) MatLab Script:-

radius='Enter Radius of cylinder in cm: ';
height='Enter Height of cylinder in cm: ';
R=input(radius);
H=input(height);
A=2*pi*R*H;
fprintf('Cylinder Radius is %d cm Cylinder Height is %d cm Cylinder Surface Area is %d sqcm ',R,H,A);

Output:-

Enter a number: 4
value of x is 4
value of x^2 is 16
value of x^0.5 is 2

Enter Radius of cylinder in cm: 3
Enter Height of cylinder in cm: 5.2
Cylinder Radius is 3 cm
Cylinder Height is 5.200000e+000 cm
Cylinder Surface Area is 9.801769e+001 sqcm
>>

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