serious answers only please . I blurred some links in the question because answers would not let me post it with links

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

serious answers only please . I blurred some links in the question because answers would not let me post it with links

Post by answerhappygod »

serious answers only please . I blurred some links in thequestion because answers would not let me post it withlinks
Serious Answers Only Please I Blurred Some Links In The Question Because Chegg Would Not Let Me Post It With Links 1
Serious Answers Only Please I Blurred Some Links In The Question Because Chegg Would Not Let Me Post It With Links 1 (90.57 KiB) Viewed 36 times
PROG24178 Arbitrary Precision Pi Calculator (15 marks / 3%) In this assignment you'll implement a high-precision calculation of the mathematical constant . You'll be creating your first basic JavaFX GUI, and learn how to use the BigDecimal class from the Java library. It's highly recommended that you do this program in three steps: 1. Enter the double floating point version of the Pi calculation given below and get it working as a console program. Play with it a bit. 2. Convert the program to an arbitrary precision calculation using the BigDecimal class. Test it by calculating to 1000 decimal places. To verify your program you can compare your results to this web page (note the last 3 digits are wrong):( 3. Convert to a GUI application by adding JavaFX GUI components. Hand in your final program (you do not need to hand in the programs from step 1 or 2). Double Floating Point Pi Calculation In 1706 John Machin discovered a formula for calculating Pi that converges quickly. That means you don't need to iterate (repeat) the formula very long to calculate many digits of T. Machin's formula is shown below: TL 4 = 4 arctan (-/-) - = arctan 239. He used his formula along with the Taylor Series expansion of arctangent to calculate to 100 decimal places. For more information see this link:
PROG24178 We'll use Machin's formula in our π calculating program. Don't worry, you don't have to fully understand the formula. The method calculatePi below shows how to calculate using the 'double' data type. // Calculate Pi using Machin's formula and the Taylor series expansion of arctangent. double calculatePi(int iterations) { double result = 0; // The result (summation of Taylor series) double oddNum = 1; // Odd numbers (1, 3, 5, 7 etc.) double pow5 = 5. // Odd powers of 5 (5^1, 5^3, 5^5 etc.) double pow239 = 239: Odd povers of 239 (239 1. 239 3, 239^5 etc.) double sign 1; // Either 1 or -1 indicating the sign of the next term. for (int count = 0; count <iterations; count++) { // Calculate and add the next term in the series // The sign of each new term alternates double next Term 16.0 (pov5* oddNun) 4.0 (pow239 * oddNum); result + sign *nextTerm: // Update variables for next time around loop pow5 pov5 * 5 * 5: pow239 pow239 239 239; oddNum += 2: sign-sign; } } return result; The parameter controls the number of iterations (repetitions of the loop) in the calculation. Try it out... you'll notice that you don't need very many iterations before you reach the maximum precision of 'double', about 16 digits. The last couple of digits may not be exactly correct because of roundoff errors. What we need is a way to calculate with many many more digits of precision! Pi Calculation With BigDecimal Class. Update your program so that it uses the BigDecimal class, found in the java.math package, for all calculations (see textbook section 10.14). When using this class you can't write expressions using regular Java operators like +, -, *, /. You have to use method calls like add, subtract, multiply, divide. For example, here is how you would calculate 16* (-4+125) BigDecimal a = new BigDecimal (16); BigDecimal b = new BigDecimal (-4); BigDecimal c = new BigDecimal (125); BigDecimal result = a.multiply (b.add (c));
PROG24178 Notice that since there are no BigDecimal literals, the first three lines turn regular numbers into BigDecimal objects by using a certain constructor. To control the number of decimal places used in the calculation we have to tell the BigDecimal divide method what precision to use and how to round off. For example, this calculates 22/7 to 1000 decimal places and prints the result: BigDecimal a = new BigDecimal (22); BigDecimal b = new BigDecimal (7); BigDecimal result = a.divide (b, 1000, RoundingMode. HALF UP); System.out.println("The answer is " + result); You should use the divide method in this way whenever your program needs to divide numbers. You don't need to give a precision when adding, multiplying etc. JavaFX GUI So far your program just uses the console. Now convert it into a JavaFX GUI application. Your GUI should have one window with the following components: . A text field for the user to enter the desired precision (number of decimal places). A text field for the user to enter the number of iterations in the calculation. A button to start the calculation. A fairly large text area to display the result. Make sure that at least 1000 digits of can fit. Labels and any other components required to make your GUI look good and be easy to use. Design your classes and methods appropriately. You must use Scene Builder to build your GUI. Notes and features To make your GUI look a bit fancier put in some extra touches like a welcome message or a picture (JPEG). For full marks you should not use the keyword 'static' except for the main method declaration and for constant (final) fields.
PROG24178 If you're interested in seeing how many digits of you can calculate, you'll find that there are much more advanced a calculating formulas and programs out there. A free PC program called y-cruncher is the current world record holder for Pi calculations, with it you can easily calculate a few hundred million or a billion digits, maybe more. Download it here: Assignment Submission Your submission must follow all the submission requirements outlined below. Do your work individually. This is not a group assignment. Submit your assignment using SLATE (click on the Dropbox tab, then click on the correct assignment link). Attach your exported eclipse project to your submission. Your assignment must be submitted before the due date/time. Any assignments submitted after this time are considered late. See our class plan on SLATE for my rules governing late assignments. If your assignment is more than five days late you will receive a mark of zero. Evaluation Your submission will be evaluated based on the following criteria: Efficient Code: Program doesn't use too much repetitive code (e.g. uses methods instead of copy/pasting code). Program uses variables where and only when necessary; program doesn't define variables that are never used, nor does it use too many variables for unnecessary tasks. Program logic is written concisely and is not cluttered with unnecessary code. Functionality: Program functions according to specifications. Programming Style: Proper indentation and spacing, use of comments; all identifiers are descriptive and follow our coding standards; variables are defined with appropriate types and converted when required. External Documentation (if any): Good organization and clarity of written communication.
PROG24178 Other: All instructions regarding submissions and program specifications have been followed; submission was completed as requested in a timely fashion. Techniques discussed in class have been used as appropriate.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply