Question: ex2 a and b Review Exercise 4 from Lab 2. a) Write a method called convertDistance that takes a double and a Boolean parameter and
Review Exercise 4 from Lab 2. a) Write a method called convertDistance that takes a double and a Boolean parameter and returns a double value that is calculated by converting between kilometres and miles. The method should convert the double parameter into either kilometres or miles, depending on the value of the Boolean parameter. Your method should convert from kilometres into miles if the Boolean parameter is true, and should convert from miles into kilometres otherwise. b) Write a main method that prints to output two prompts for the user, and after each prompt pauses to collect input from the user using the Scanner class. Prompt the user once for a number of kilometres, and convert this into miles, and also prompt the user for a number of miles, which should be converted into miles. Use nicely formatted output that makes clear both the input and output. For instance, your main method could print out something like: There are 6.21371 miles in 10.0 kilometres! There are 8.04672 kilometres in 5.0 miles! Review Exercise 5 from Lab 3. a) Write a method called circleCirc that takes a single double parameter and returns a double value that is equal to the circumference of a circle. The method should calculate the circumference using the absolute value of the double parameter as the circles radius. b) Write a method called circleArea that takes one double parameter and returns a double value that is equal to area of a circle. The method should calculate the area using the absolute value of the double parameter as the circles radius
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
