Question: Using Mips 32/Mars. Do not write code for Area of circle, square and rectangle that is not the objective! Surface area for sphere and cube
-
Using Mips 32/Mars.
-
Do not write code for Area of circle, square and rectangle that is not the objective! Surface area for sphere and cube are only to be computed!
-
Write an assembly language program that prompts the user for and reads four integers (x1, y1, x2, y2) which represent the coordinates of two points. Make sure you keep track of which number is which.
-
Treat the line between the points as the radius of a sphere and compute the surface area of the sphere. Print the output with a label, such as The surface area of the sphere is: .... Hint: The distance between the points is the square root of ((x2 x1)2 + (y2 y1)2). However, since you have to square the radius, to get the area, you dont need to worry about calculating the square root. Just use ((x2 x1)2 + (y2 y1)2) in place of r2. To work with , do what the text book does on page 14. Use 314159 as and do the calculations. At the end, divide by 100000 and the quotient is your answer. Note that the answer will be an integer, which is fine.
Formula: Surface Area = 4r2
-
Once part 2 is working properly, add code to treat the line between the points as the side of a cube and compute the surface area of the cube. The calculation is similar to what you did in part 2 except for the multiplication by . Print the output with an appropriate label. Formula: Surface Area = 6*side2
-
Add labels above each of the calculation code segments such (sphere: and cube:). Add a menu to the program that prompts the user as follows:
To quit enter 0 To calculate the surface area of a sphere enter 1 To calculate the surface area of a cube enter 2 Enter your choice:
If the user enters 0, the program terminates. Otherwise, the user enters the four values and you branch to the correct calculation area and output area. This may require several branching instructions. Once a calculation is made, you loop back to the menu.
-
Test the problem with the following data: x1: 1, y1: 1, x2: 3, y2: 3, Surface area of sphere:100 Surface area of cube:48 x1: 20, y1: 30, x2: 40, y2: 50, Surface area of sphere:10053 Surface area of cube:4800
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
