First, write five methods that compute and return the following: 1.Area of a circle. This method...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
First, write five methods that compute and return the following: 1.Area of a circle. This method takes one parameter, the radius. public static double areaCircle (int radius) 2.Area of a rectangle. This method takes two parameters, the length and width public static int areaRectangle (int length, int width) 3.Area of a square. This method takes one parameter, the length of a side. public static int areaSquare (int side) However, because a square is just a special type of rectangle (where the sides have the same length), have this function call your area of a rectangle function to compute the answer. In other words, do not directly compute the area of a square inside this function, instead, call your area of a rectangle function with appropriate arguments and return the value that comes back. 4.The surface area of a rectangular prism. This method takes three parameters, the length, width, and height. public static int areaPrism (int length, int width, int height) This method takes three parameters, the length, width, and height. 5. The area of a ring, meaning a circle with an interior circle missing, like this. This function takes two parameters, the inner radius and the outer radius. public static double areaRing (int radouter, int radInner) Your area of a ring function should call your area of a circle method twice. Second, write your main method to do this: The user is first asked what kind of shape they want to calculate the area (or surface area) of. The user will type in the name of the shape as a string (e.g., circle, rectangle, square, prism, or ring). Use if-else statements to figure out what shape they wanted, then ask the user to type in the appropriate attributes of the shape (e.g., for circle you would ask for the area, for square you would ask for the length of a side). If the user types in an invalid shape name, then print an appropriate error message. Display the area of the shape, followed by a message asking the user if they want to calculate the area of another shape. If they answer yes, then run the program again. You should use a while loop for this part. Lastly Test your program Sample output that I made with my program: What shape do you want? square What is the side length? 7 The area of the square is 49 Do you want to calculate another area? yes What shape do you want? rectangle What is the length? 8 What is the width? 5 The area of the rectangle is 40 Do you want to calculate another area? yes What shape do you want? prism What is the length? 6 What is the width? 5 What is the height? 4 The surface area of the prism is 148 Do you want to calculate another area? yes What shape do you want? Hexagon I don't know that shape. Do you want to calculate another area? yes What shape do you want? square What is the side length? 5 The area of the square is 25 Do you want to calculate another area? yes What shape do you want? Ring What is the outer radius? 6 What is the inner radius? 4 The area of the ring is 62.83185307179586 What shape do you want? Circle What is the radius? 6 The area of the circle is 113.03999999999999 Do you want to calculate another area? no First, write five methods that compute and return the following: 1.Area of a circle. This method takes one parameter, the radius. public static double areaCircle (int radius) 2.Area of a rectangle. This method takes two parameters, the length and width public static int areaRectangle (int length, int width) 3.Area of a square. This method takes one parameter, the length of a side. public static int areaSquare (int side) However, because a square is just a special type of rectangle (where the sides have the same length), have this function call your area of a rectangle function to compute the answer. In other words, do not directly compute the area of a square inside this function, instead, call your area of a rectangle function with appropriate arguments and return the value that comes back. 4.The surface area of a rectangular prism. This method takes three parameters, the length, width, and height. public static int areaPrism (int length, int width, int height) This method takes three parameters, the length, width, and height. 5. The area of a ring, meaning a circle with an interior circle missing, like this. This function takes two parameters, the inner radius and the outer radius. public static double areaRing (int radouter, int radInner) Your area of a ring function should call your area of a circle method twice. Second, write your main method to do this: The user is first asked what kind of shape they want to calculate the area (or surface area) of. The user will type in the name of the shape as a string (e.g., circle, rectangle, square, prism, or ring). Use if-else statements to figure out what shape they wanted, then ask the user to type in the appropriate attributes of the shape (e.g., for circle you would ask for the area, for square you would ask for the length of a side). If the user types in an invalid shape name, then print an appropriate error message. Display the area of the shape, followed by a message asking the user if they want to calculate the area of another shape. If they answer yes, then run the program again. You should use a while loop for this part. Lastly Test your program Sample output that I made with my program: What shape do you want? square What is the side length? 7 The area of the square is 49 Do you want to calculate another area? yes What shape do you want? rectangle What is the length? 8 What is the width? 5 The area of the rectangle is 40 Do you want to calculate another area? yes What shape do you want? prism What is the length? 6 What is the width? 5 What is the height? 4 The surface area of the prism is 148 Do you want to calculate another area? yes What shape do you want? Hexagon I don't know that shape. Do you want to calculate another area? yes What shape do you want? square What is the side length? 5 The area of the square is 25 Do you want to calculate another area? yes What shape do you want? Ring What is the outer radius? 6 What is the inner radius? 4 The area of the ring is 62.83185307179586 What shape do you want? Circle What is the radius? 6 The area of the circle is 113.03999999999999 Do you want to calculate another area? no
Expert Answer:
Answer rating: 100% (QA)
import javautil class area public static int decideString shap... View the full answer
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these marketing questions
-
Use the fact that the area of a circle of radius r is r2 to find the volume of a cone of height 1 that has radius r at a height r. Think of the cone as being built of a stack of little circular disks...
-
What is the rate of change of the area of a circle with respect to the radius when the radius is r = 3 in.?
-
What is the area of a circle of radius (a) 11.37 m (b) 6.8 m?
-
Creativity and Innovation Management (Feb. 2008) published an article on identifying the social network characteristics of lead users of children's computer games. Data were collected for n = 326...
-
What was Bank Transfer Day?
-
Define revenues, expenses and net income. How is the accounting equation expanded to record income-related transactions?
-
Why is an ethical culture considered necessary for fraud prevention and deterrence?
-
Machinery purchased for $52,000 by Carver Co. in 2008 was originally estimated to have a life of 8 years with a salvage value of $4,000 at the end of that time. Depreciation has been entered for 5...
-
. Imagine you have an on-premises eCommerce site for a small local jewelry store. . The jewelry store sells rings, watches, necklaces and bracelets. . Review Amazon Web Services, Microsoft Azure and...
-
The shaded area in the following graph represents the feasible region of a linear programming problem whose objective function is to be maximized. Label each of the following statements as True or...
-
On June 30 of the current year, the assets and liabilities of Sting Industries are as follows: Accounts Payable: $2585 Accounts Receivable: $1787 Cash: $1066 Land: $3747 Supplies: $218- How much is...
-
Goodsons has variable costs of $2 per unit and fixed costs of $40,000. Goodsons' selling price is $5 per unit. How much profit will Goodsons earn if it cuts its selling price to $3 per unit, and...
-
The Daniel Insurance Agency reported revenues of $34,000 and expenses of $38,300 for the current period. What was the final figure reported on the company's income statement?
-
PARTICIPATION ACTIVITY 1.4.2: Common syntax errors. Treat the following lines of code as a continuous program. Find and click on the three syntax errors. 1) triangle_base= 0 # Triangle base (cm)...
-
The Financial Post is writing an editorial about recent changes to personal income tax that will affect tax returns that are due within the next few months. By doing this the Post is most likely...
-
Green Landscaping, Inc. is using net present value (NPV) when evaluating projects. Green Landscapings cost of capital is 11.71 percent. What is the NPV of a project if the initial costs are...
-
The Blending Department of Wildhorse Company has the following cost and production data for the month of April. Costs: Work in process, April 1 Direct materials: 100% complete Conversion costs: 20%...
-
Find the APR in each of the following cases: NUMBER OF TIMES COMPOUNDED Semiannually Monthly Weekly Infinite EAR APR 10.4% 8.9 11.6 15.4
-
Using the A , B , C , and D classes from this section, what is the output of the following code fragment? public static void main (String [] args) { A[] elements {new B(), new D(), new A (), new...
-
Write methods rotateLeft and rotateRight that rotate the pixels of an image counter-clockwise or clockwise by 90 degrees respectively. You should not assume that the image is square in shape; its...
-
Write a method called longestSortedSequence that returns the length of the longest sorted sequence within a list of integers. For example, if a variable called list stores [1, 3, 5, 2, 9, 7, 3, 0,...
-
In the section of his 2007 letter to the shareholders of Berkshire Hathaway titled Fanciful FiguresHow Public Companies Juice Earnings, Warren Buffett referred to the investment return assumption...
-
Based on 2012 revenues, the six largest providers of oilfield services are: 1. Schlumberger Ltd. (NYSE: SLB) Revenues: $42.1 billion Net income: $5.5 billion 2. Halliburton (NYSE: HAL) Revenues:...
-
On 21 September 2000, Intel Corporation (NASDAQ -GS: INTC)3 issued a press release containing information about its expected revenue growth for the third quarter of 2000. The announced growth fell...
Study smarter with the SolutionInn App