Question
Write the following code in main Define the following variables to hold the circle data: Variable radius : type double Variable area : type double
Write the following code in main
- Define the following variables to hold the circle data:
- Variableradius: type double
- Variablearea: type double
- Variablecircumference: type double
Then write the code to assign the value1.2 to the radius variable.
B. Define anamed constant with the namePI and initialize it with a value3.14159 and use this for later calculation.
Do not use C++ M_PI constant in cmath.
C. Add the "#include" for string class at the top.
Define anamed constant of string typeAREA_STR that containsexactly the text (no extra space).
"Area of the circle with radius"
D. Define anamed constant of string typeCIRCUM_STR that containsexactly the text (no extra space).
"Circumference of the circle with radius"
E. Display the literal string "My name is XXXXXX"to the output console.
F. Provide a line of code to calculate the circle area using theradius variable andPI, and store the result in thearea variable.
G. Provide a line of code to calculate the circle circumference using theradius variable andPI, and store the result in thecircumference variable.
H. Provide a line of code to display to output console:
Area of the circle with radius XX is YY.
using the named constant AREA_STR,radius and thearea variable. The value XX comes from the radius variable. The value YY comes from thearea variable.
You can add extra space characters to the output line, but you should use the AREA_STR constant to avoid duplicating text.
I. Provide code to print an output line
Circumference of the circle with radius XX is YY.
using the named constant CIRCUM_STR, radius variable and thecircumference variable. The value XX comes from the radius variable. The value YY comes from thecircumference variable.
You can add extra space characters to the output line, but you should use the CIRCUM_STR constant to avoid duplicating text.
J. Build and test your code
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started