Homework 12

This assignment is a modification of your last homework assignment. The changes are in the miscellaneous requirements at the bottom.

Output Requirements

Output the radius, diameter, circumference, and area of a circle. Each value is to be displayed on a separate line and labeled and formatted as illustrated below.

Sample Run

 Input Requirements

Ask the user to enter the value of the radius.

Process Requirements

Calculate the diameter (2r), the circumference (2πr), and the area (πr2) of the corresponding circle. You may assume that the user will enter a positive value for the radius.

Miscellaneous Requirements

Use a void function named "displayInstructions" to display the instructions. This function has no parameters.

Use a void function named "getRadius" to get the radius from the user. This function has one double type parameter which is used to return the value entered by the user. This function should validate the user's entry. If the entered radius is negative, then an appropriate error message should be displayed and the user should be asked to enter another value. This process continues as long as the user enters negative values (see sample run illustration above). When the user enters a non-negative value, the function returns that value via the double type parameter.

Use a void function, named "displayResults", to display the output. This function should have four double type parameters corresponding to the radius, the diameter, the circumference, and the area.

In the main function of your program, all of the code you wrote for displaying the instructions should be replaced with the invocation of the displayInstructions function. The code you wrote for getting the radius from the user should be replaced with the invocation of getRadius. The code you wrote to display the results should be replaced with the invocation of displayResults.