Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment you will use structured programming in the Java language to estimate PI or the ratio of the circumference of a circle to

In this assignment you will use structured programming in the Java language to estimate PI or the ratio of the circumference of a circle to the diameter. The class and the methods will be documented using JavaDoc style comments. The output will be posted to the answer portion of the essay question. The source code will be attached to the assignment. You may use anything found in the first 3 Chapters of the book. Area of a Circle We will leverage the fact that the area of a circle is defined as where A is the area, r is the radius, and is the ratio of the circumference of a circle to the diameter. The standard form of the equation for a circle is where (, ) is the center of the circle, r is the radius and (x,y) is a point of the circle. If we center the circle at the origin, then the equation becomes . Solving for y gives If f(x) = then half of the area of the circle may be estimated using the following equation . This will give us an estimate of the area of the top of the circle. PI can then be estimated by multiplying the sum by 2 and dividing it by . Instructions Write a function to compute the positive value of y given the value of x and the radius. Use the standard form of the equation of a circle provided above. Document this function with JavaDoc comments explaining the purpose of each parameter. Write a function to estimate the area of the top half of the circle defined by the radius. This will be the sum of the value of as i goes from -r to r in increments of 1. Document this function with JavaDoc comments explaining the purpose of each parameter. Estimate PI using radii of 1.0E1, 1.0E2, 1.0E3, 1.0E10. For each radus write the following statement replacing the italic variables with their numeric value , At a radius of r the estimate of PI is pi with a difference of Math.PI pi

Learning Objectives The program will be graded as to how well it produces the desired results and demonstrates the following learning objectives. 1. Decompose a problem into manageable chunks. 2. Implement those chunks using static methods. 3. Remove as much redundancy as practical. 4. Demonstrate a mastery of variables. 5. Demonstrate a mastery of the for loop. 6. Demonstrate the ability to pass parameters into a method. 7. Demonstrate the ability to receive a value from a method. 8. Properly format the code to clearly show the structure of the program. 9. Comment your code Comments JavaDoc comments will be used to document the class and all methods. A JavaDoc comment is opened with a forward slash and 2 asterisks, and it is closed with an asterisk and a forward slash, (i.e., /** */). The first line a brief description which is usually followed by a black line and then a longer description. JavaDoc comments may contain tags. Tags are introduced with the each symbol, (i.e., @.) There are several tags; however, only the @author and @param tags are needed at this point. See the example provided below. Javadoc comments should be place right above the class or method that they document. See the example provided below. Indentation The program will be formatted using indentation to show the structure. A level of indentation may be two or three spaces; however, either two or three spaces should be used as one level of indentation consistently throughout the program. At least one line but no more than three lines will separate methods. The methods should be indented one level from the class. For example: Public class HelloWorld { public static void main( String[] args ) { System.out.println( Hello world! ); } }

For methods the opening curly bracket will be on the same line as the method name and parameters. The code of the method will be indented at least one level. The closing curly bracket will be on a line by itself under the beginning of the first line of the method. For example:

public static void mystery() { statement1; statement2; statement3; } For loops will be formatted with the opening curly bracket on the same line as the for statement. The code of the for loop will be indented at least one level. The closing curly bracket will be on a line by itself under the f of the for statement. For example: for (int i = 0; i < 10; i++) { statement; statement; statement; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 12th Asian Conference ACIIDS 2020 Phuket Thailand March 23 26 2020 Proceedings

Authors: Pawel Sitek ,Marcin Pietranik ,Marek Krotkiewicz ,Chutimet Srinilta

1st Edition

9811533792, 978-9811533792

More Books

Students also viewed these Databases questions