Programming Assignment: Volume Comparison Problem Statement: This assignment will acquaint you with the use of parameter...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Programming Assignment: Volume Comparison Problem Statement: This assignment will acquaint you with the use of parameter passing, return values, if/else blocks, and user input. You will create a program that prompts the user for a set of information, then executes simple algebra on that information and returns a summary report. Specifically, your program will ask the user to specify two simple geometric shapes along with their dimensions. The program will then calculate and report the volumes of both shapes and print a summary statement comparing the two shapes. Write a complete class called Volume Comparison that has the following: (4 points) getShapeType method: that prompts the user for the type of the shape and returns the lower case version of the shape type ("box", "cone" or "sphere"). (4 points) promptCalculate PrintBoxVolume method: prompts the user for the dimensions of the box (width, depth and height), calculates, reports it to console and returns the volume of the box. . (4 points) promptCalculate PrintConeVolume method: prompts the user for the dimensions of the cone (radius and height), calculates, reports it to console and returns the volume of the cone. (4 points) promptCalculate PrintSphereVolume method: prompts the user for the dimensions of the sphere (radius), calculates, reports it to console and returns the volume of the sphere. (4 points) promptCalculateVolume method: takes shape type as input parameter and calls one of the three promptCalculate Print* methods above depending on the shape type and returns the volume reported by that method. If the shape type is not one of the known ones (box, cone or sphere), this method should throw an IllegalArgumentException. (6 points) main method: Declares and initializes a Scanner object to be used throughout to read user input. Calls methods getShapeType and promptAnd Calculate Volume methods successively to get the shape type and volume for two shapes. o Compares these two values and prints the final report. When printing the volumes, make sure the numbers are printed rounded to 3 decimal places. (4 points) - Include appropriate program documentation and formatting including: Your first and last name, the date of submission, code comments necessary to explain the operation of your program, and proper indentation of the code, etc. O Tips: ● ● For each of the methods, think about the following: What is the return type, what parameter(s) will it need to perform the task, and accordingly decide the method signature for each. To be able to use the single Scanner object effectively you will have to pass it to all the methods that prompt the user for input. You can look up the formulae for the volume of different shapes online. You can use Math.Pl for the value of Pi When comparing strings, use the equals method to compare the values of the strings. When printing the volumes, make sure the numbers are printed rounded to 3 decimal places. Sample run 1 (text in orange is what user has entered as input): Please choose your shape (box, cone, or sphere): box Specify box width: 35 Specify box depth: 25 Specify box height: 22.5 The volume of the box is (19687.500) cube units. Please choose your shape Specify sphere radius: The volume of the sphere is (179594.380) cube units. (box, cone, or sphere): sphere 35 The volume of the box (19687.500 cube units) is less than the volume of the sphere (179594.380 cube units) Sample run 2 (text in orange is what user has entered as input): Please choose your shape (box, cone, or sphere): sphere Specify sphere radius: 15 The volume of the sphere is (14137.167) cube units. Please choose your shape (box, cone, or sphere): cone Specify cone base: 25 Specify cone height: 15 The volume of the cone is (9817.477) cube units. The volume of the sphere (14137.167 cube units) is greater than the volume of the cone (9817.477 cube units). Sample run 3 (text in orange is what user has entered as input): Please choose your shape (box, cone, or sphere): box Specify box width: 22 Specify box depth: 10 Specify box height: 24 The volume of the box is (5280.000) cube units. Please choose your shape (box, cone, or sphere): box Specify box width: 12 Specify box depth: 44 Specify box height: 10 The volume of the box is (5280.000) cube units. The volume of the box (5280.000 cube units) is equal to the volume of the box (5280.000 cube units). Sample run 4 (text in orange is what user has entered as input): Please choose your shape (box, cone, or sphere): pyramid Exception in thread "main" java.lang.IllegalArgumentException: Unknown shape at Volume Comparison.promptAndcalculateVolume (Volume Comparison.java:49) at Volume Comparison .main (Volume Comparison.java:15) Programming Assignment: Volume Comparison Problem Statement: This assignment will acquaint you with the use of parameter passing, return values, if/else blocks, and user input. You will create a program that prompts the user for a set of information, then executes simple algebra on that information and returns a summary report. Specifically, your program will ask the user to specify two simple geometric shapes along with their dimensions. The program will then calculate and report the volumes of both shapes and print a summary statement comparing the two shapes. Write a complete class called Volume Comparison that has the following: (4 points) getShapeType method: that prompts the user for the type of the shape and returns the lower case version of the shape type ("box", "cone" or "sphere"). (4 points) promptCalculate PrintBoxVolume method: prompts the user for the dimensions of the box (width, depth and height), calculates, reports it to console and returns the volume of the box. . (4 points) promptCalculate PrintConeVolume method: prompts the user for the dimensions of the cone (radius and height), calculates, reports it to console and returns the volume of the cone. (4 points) promptCalculate PrintSphereVolume method: prompts the user for the dimensions of the sphere (radius), calculates, reports it to console and returns the volume of the sphere. (4 points) promptCalculateVolume method: takes shape type as input parameter and calls one of the three promptCalculate Print* methods above depending on the shape type and returns the volume reported by that method. If the shape type is not one of the known ones (box, cone or sphere), this method should throw an IllegalArgumentException. (6 points) main method: Declares and initializes a Scanner object to be used throughout to read user input. Calls methods getShapeType and promptAnd Calculate Volume methods successively to get the shape type and volume for two shapes. o Compares these two values and prints the final report. When printing the volumes, make sure the numbers are printed rounded to 3 decimal places. (4 points) - Include appropriate program documentation and formatting including: Your first and last name, the date of submission, code comments necessary to explain the operation of your program, and proper indentation of the code, etc. O Tips: ● ● For each of the methods, think about the following: What is the return type, what parameter(s) will it need to perform the task, and accordingly decide the method signature for each. To be able to use the single Scanner object effectively you will have to pass it to all the methods that prompt the user for input. You can look up the formulae for the volume of different shapes online. You can use Math.Pl for the value of Pi When comparing strings, use the equals method to compare the values of the strings. When printing the volumes, make sure the numbers are printed rounded to 3 decimal places. Sample run 1 (text in orange is what user has entered as input): Please choose your shape (box, cone, or sphere): box Specify box width: 35 Specify box depth: 25 Specify box height: 22.5 The volume of the box is (19687.500) cube units. Please choose your shape Specify sphere radius: The volume of the sphere is (179594.380) cube units. (box, cone, or sphere): sphere 35 The volume of the box (19687.500 cube units) is less than the volume of the sphere (179594.380 cube units) Sample run 2 (text in orange is what user has entered as input): Please choose your shape (box, cone, or sphere): sphere Specify sphere radius: 15 The volume of the sphere is (14137.167) cube units. Please choose your shape (box, cone, or sphere): cone Specify cone base: 25 Specify cone height: 15 The volume of the cone is (9817.477) cube units. The volume of the sphere (14137.167 cube units) is greater than the volume of the cone (9817.477 cube units). Sample run 3 (text in orange is what user has entered as input): Please choose your shape (box, cone, or sphere): box Specify box width: 22 Specify box depth: 10 Specify box height: 24 The volume of the box is (5280.000) cube units. Please choose your shape (box, cone, or sphere): box Specify box width: 12 Specify box depth: 44 Specify box height: 10 The volume of the box is (5280.000) cube units. The volume of the box (5280.000 cube units) is equal to the volume of the box (5280.000 cube units). Sample run 4 (text in orange is what user has entered as input): Please choose your shape (box, cone, or sphere): pyramid Exception in thread "main" java.lang.IllegalArgumentException: Unknown shape at Volume Comparison.promptAndcalculateVolume (Volume Comparison.java:49) at Volume Comparison .main (Volume Comparison.java:15)
Expert Answer:
Answer rating: 100% (QA)
FileName VolumeComparisonjava import javautilScanner public class VolumeComparison public static void mainString args Scanner scanner new ScannerSyste... View the full answer
Related Book For
Financial and Managerial Accounting the basis for business decisions
ISBN: 978-0078025778
17th edition
Authors: Jan Williams, Susan Haka, Mark Bettner, Joseph Carcello
Posted Date:
Students also viewed these programming questions
-
In this question you will be asked to reflect on a project you have been involved in or observed, in which a design evolved, or could have evolved, through applying a theory of user behaviour. You...
-
In a Hopfield neural network configured as an associative memory, with all of its weights trained and fixed, what three possible behaviours may occur over time in configuration space as the net...
-
As the marketing manager for a local shopping center, you are asked to prepare a report outlining the external influences that should be considered in the situation analysis. Describe each category...
-
Different types of posting errors are identified in following table. For each, indicate (a) Trial balance will balance, (b) The amount of the difference if the trial balance will not balance, (c) The...
-
Provide an example of a manual control activity that is dependent on a system-generated report for its effective operation.
-
Many researchers are interested in the transcription of protein-encoding genes in eukaryotes. Such researchers want to study mRNA. One method that is used to isolate mRNA is column chromatography....
-
Presented below are the captions of Nikos Companys balance sheet. (a) Current assets. (b) Investments. (c) Property, plant, and equipment. (d) Intangible assets . (e) Other assets. (f) Current...
-
2024 2023 2022 Sales $ 78,000 Cost of goods sold 62,400 $ 70,000 60,900 $ 59,000 44,100 2021 $ 58,000 35,100 2020 $ 50,000 30,000 Required: Dollar amounts stated are in thousands. a. Compute trend...
-
How to build effective relationship with customers in IT industry
-
You have just graduated and will need a new car to travel to work (public transit is not available for travel to Middle Musquodoboit). A suitable vehicle was found at the local car dealership and the...
-
What role should the government play in providing support to families for the care of their elder family members? Should we be passing laws to substantially increase government assistance to families...
-
A solid has a volume of 6 cubic units and a surface area of 22 square units. The solid is dilated, and the image has a volume of 384 cubic units. Answer the following question: The scale factor of...
-
what ways do individual values intersect with broader societal values, and how do conflicts between personal convictions and societal expectations impact identity formation and social cohesion?
-
Does the law strengthen or weaken the family unit in China? Discuss in detail
-
Write a paper on the topic (The Impact of Digital Marketing on Consumer Behavior: Telecom Industry Context).
-
A fast-food restaurant averages 150 customers per hour. The average processing time per customer is 90 seconds. a. Determine how many cash registers the restaurant should have if it wishes to...
-
Floyd Christianson is the chief executive officer of Murango Pharmaceuticals. The company has been struggling in recent years to break even and its stock price has been on the decline. The companys...
-
Joyce Biginskor manages the Assembly Department at Valance Autoparts, a parts supplier to large auto companies. Valance has recently adopted a balanced scorecard for the entire company. As a result,...
-
Explain why the Dividends account is closed directly to the Retained Earnings account.
-
Which of the following best describes the underlying rationale for a written investment policy statement (IPS)? A. A written IPS communicates a plan for trying to achieve investment success. B. A...
-
Which of the following is least important as a reason for a written investment policy statement (IPS)? A. The IPS may be required by regulation. B. Having a written IPS is part of best practice for a...
-
Which of the following is least likely to be placed in the appendices to an investment policy statement (IPS)? A. Rebalancing Policy. B. Strategic Asset Allocation. C. Statement of Duties and...
Study smarter with the SolutionInn App