* Write an application that inputs from the user the radius of a circle as an...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
* Write an application that inputs from the user the radius of a circle as an integer and * prints the circle's diameter, circumference and area using the floating-point value 3.14159 for n. * Use the techniques shown in Fig. 2.7. * [Note: You may also use the predefined constant Math.PI for the value of A. * This constant is more precise than the value 3.14159. Class Math is defined in package java.lang. * Classes in that package are imported automatically, so you do not need to import class Math to use it.] * Use the following formulas (r is the radius): * diameter = 2r * circumference = 2nr area = nr 2 * Do not store the results of each calculation in a variable. Rather, specify each calculation as the * value that will be output in a System.out.printf statement. Note that the values produced by the * circumference and area calculations are floating-point numbers. Such values can be output with the * format specifier %f in a System.out.printf statement. */ public class Exercise0222 // main method begins execution of Java application public static void main(String[] args) { // create Scanner to obtain input from command window Scanner input = new Scanner(System.in); int r; // user input for circle's radius System.out.print("Enter the radius of the circle: "); // prompt r = input.nextInt(); // read radius input !3! System.out.printf("Diameter of the circle is Xd\n", (2 * r)); // calculates the diameter System.out.printf("Circumference of the circle is %.2f\n", (2* (Math.PI) * r)); // calculates the circumference System.out.printf("Area of the circle is %.2f\n", ((Math.PI) (r * r))); // calculates the area } // end method main } // end class Exercise0222 /* Output: * Enter the radius of the circle: 6 * Diameter of the circle is 12 * Circumference of the circle is 37.70 * Area of the circle is 113.10 */ * Write an application that inputs from the user the radius of a circle as an integer and * prints the circle's diameter, circumference and area using the floating-point value 3.14159 for n. * Use the techniques shown in Fig. 2.7. * [Note: You may also use the predefined constant Math.PI for the value of A. * This constant is more precise than the value 3.14159. Class Math is defined in package java.lang. * Classes in that package are imported automatically, so you do not need to import class Math to use it.] * Use the following formulas (r is the radius): * diameter = 2r * circumference = 2nr area = nr 2 * Do not store the results of each calculation in a variable. Rather, specify each calculation as the * value that will be output in a System.out.printf statement. Note that the values produced by the * circumference and area calculations are floating-point numbers. Such values can be output with the * format specifier %f in a System.out.printf statement. */ public class Exercise0222 // main method begins execution of Java application public static void main(String[] args) { // create Scanner to obtain input from command window Scanner input = new Scanner(System.in); int r; // user input for circle's radius System.out.print("Enter the radius of the circle: "); // prompt r = input.nextInt(); // read radius input !3! System.out.printf("Diameter of the circle is Xd\n", (2 * r)); // calculates the diameter System.out.printf("Circumference of the circle is %.2f\n", (2* (Math.PI) * r)); // calculates the circumference System.out.printf("Area of the circle is %.2f\n", ((Math.PI) (r * r))); // calculates the area } // end method main } // end class Exercise0222 /* Output: * Enter the radius of the circle: 6 * Diameter of the circle is 12 * Circumference of the circle is 37.70 * Area of the circle is 113.10 */
Expert Answer:
Answer rating: 100% (QA)
For designing an application that inputs from the us... View the full answer
Related Book For
Modeling the Dynamics of Life Calculus and Probability for Life Scientists
ISBN: 978-0840064189
3rd edition
Authors: Frederick R. Adler
Posted Date:
Students also viewed these operating system questions
-
Using the Die class, write an application that randomly throws five dice for the computer and five dice for the player. Display the values and then, by observing the results, decide who wins based on...
-
Write an application that stores at least five different college courses (such as CIS101), the time it first meets in the week (such as Mon 9 am), and the instructor (such as Johnson) in a...
-
Write an application that stores at least five different department and supervisor names in a two-dimensional array. Allow the user to enter a department name (such as Marketing) and display the...
-
A mortgage loan officer uses math on a continual basis during the mortgage lending process. When a prospective borrower applies for a loan, many calculations are made: debt-to-income- ratio,...
-
Consider the data in Exercise 1.5. Compute the sample variance and the sample standard deviation for both the control and treatment groups. In Exercise 1.5 Control group: 7 3 -4 4 2 5 22 7 9...
-
Explain why and how you would adjust the problem-solving process to accommodate any of the characteristics of problems.
-
A 500-N cube of specific gravity \(S G=1.8\) falls through water at a constant speed \(U\). Determine \(U\) if the cube falls (a) as oriented in Fig. P9.80a, (b) as oriented in Fig. P9.80b. Figure...
-
1. Emerson Process Management, a global supplier of measurement, analytical, and monitoring instruments and services based in Austin, Texas, had a new data warehouse designed for analyzing customer...
-
Before automation became more prevalent, overhead was often calculated and allocated as a function of direct labor costs or direct labor hours. Discuss whether you feel this method of allocation is...
-
Shown here are retail price figures and quantity estimates for five different food commodities over 3 years. Use these data and a base year of 2007 to compute unweighted aggregate price indexes for...
-
QUESTION ONE (30 MARKS) (a) Ghana Education Service (GES) has procured new textbooks for free distribution to basic schools in the country, on 20 November, 2020 -The total cost of the procurement was...
-
Assume a money market with safe and risky borrowers. The MFI's that is ready to lend money does not know who is safe and who is risky. However experience has led the MFI to know that 50% of the...
-
Engine Builders Motor Company exports and rebuilds automobile engines that have been damaged or are in need of extensive repair. The rebuilt engine is purchased by auto shops, large motor pools in...
-
The accountant for Ericas Dress Shop prepared the following cash budget. Ericas desires to maintain a cash cushion of $20,000 at the end of each month. Funds are assumed to be borrowed and repaid on...
-
Prices as shown on 20 Dec 2018 Apple Inc :Current spot price: $ 150 CALLS PUTS Dec Jan Feb Strike Price Dec Jan Feb 5 8.85 - 149 2.67 6.6 7.93 4.25 8.35 9.65 150 3.15 7 8.38 2.97 7 7.95 152 4.2 8.1...
-
Your clients want $2,000,000 in 18 years for their retirement. If they can invest at an annual rate of 7.75%, how much do they need to save at the end of every quarter to meet the goal?
-
The following table lists twelve clauses from the Property and Stock Agents Regulation 2014 (NSW), examine each clause and give a brief analysis. (URL:...
-
Copy and complete the statement. 3800 m ? km =
-
Estimate your volume in cubic meters by pretending you are shaped like a board. Pretending that cells are cubes 20 m on a side, what do you estimate the number of cells to be by this method? The...
-
Find the 95% confidence limits if a coin is flipped seven times and comes up heads six out of seven times (Exercise 2). Find the exact confidence limits and check if the value for the earlier problem...
-
For each of the following functions, find the equation of the secant line connecting the given base point to and times t0 + t for t = 1.0, t = 0.5, t = 0.1, and t = 0.01. Sketch the function and each...
-
Put several of your ideas through the opportunity checklist in Figure 3.10. Which ideas seem to have the highest potential? Customer Identifiable Demographics Psychographics Trends Macromarket Target...
-
Subscribe to the free listserve like Fortune Term Sheet (http://fortune.com/tag/termsheet/). Track the stories on a daily basis. Which companies are receiving venture capital? What trends does this...
-
How can you shape, reshape, and refine your opportunities so that they have a greater chance to succeed and thrive?
Study smarter with the SolutionInn App