Explain in your own words how and why final variables are used. Illustrate your answer using the code below, explaining how it could be improved by the introduction of final variables. This code is intended to print the areas of 100 circles whose radius is input. The function, inputlnt, returns an integer input by the user. Note you are not required to explain or trace this code, just use it to illustrate points you make about final variables. public static void circles () { for (int i = 1; i <= 100; i ++) { int radius inputInt("What is the radius?"); = 3.14 * radius * radius; double area System.out.println(area); }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 21PE
icon
Related questions
Question

Just explain it and don't use bullet points and also the code written doesn't need to be breaker through it's just to be taken a little help from. The code is not the main thing in this question 

a)
Explain in your own words how and why final variables are used. Illustrate
your answer using the code below, explaining how it could be improved by the
introduction of final variables.
This code is intended to print the areas of 100 circles whose radius is input. The
function, inputInt, returns an integer input by the user.
Note you are not required to explain or trace this code, just use it to illustrate
points you make about final variables.
public static void circles ()
{
for (int i
= 1; i <= 100; i ++)
{
int radius
inputInt("What is the radius?");
3.14 * radius * radius;
||
double area
System.out.println(area);
}
Transcribed Image Text:a) Explain in your own words how and why final variables are used. Illustrate your answer using the code below, explaining how it could be improved by the introduction of final variables. This code is intended to print the areas of 100 circles whose radius is input. The function, inputInt, returns an integer input by the user. Note you are not required to explain or trace this code, just use it to illustrate points you make about final variables. public static void circles () { for (int i = 1; i <= 100; i ++) { int radius inputInt("What is the radius?"); 3.14 * radius * radius; || double area System.out.println(area); }
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning