Geometry Calculation
Summary
Methods package up parts of your programs into separate functions that can be run repeatedly from other parts of your code, or just used to simplify the main program and make it easier to read.
In this exercise you will develop methods for the problems posed, then combine them into a program.
Task
- Produce pseudocode and then methods for the following calculations
- The volume of a rectangular box. Hint: You will need three input parameters for height, width and length, and the return value will be the volume. Volume = length * width * height
- Determine if a triangle is right-angled from the lengths of the three sides. Hint: Use pythagoras theorem.
- Write code in your Main method to call each of these methods with some data and make sure they work.
- Now edit your Main method to ask the user which calculation they want, and then for the data required and use the correct method to calculate the answer
- Finally, give the user the option to perform another calculation or quit
Questions
- It is good practice to keep input functionality out of the methods that are actually performing the calculations and handle input separately. How would you also move the code for handling user input into separate method(s)?