Approximating : The constant, is the ratio of the circumference of a circle to its...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Approximating : The constant, "" is the ratio of the circumference of a circle to its diameter. It is known to be irrational and its decimal expansion therefore does not terminate or repeat. There are many ways to approximate . One way is to use the Nilakantha series: = (3 + 4.0/(2*3*4) - 4.0/ (4*5*6) + 4.0/ (6*7*8) - 4.0/ (8*9*10) + 4.0/(10*11*12) ...) Create a Java application in NetBeans called Lab01" and write a program called Lab01.java that displays the following to the console: Your initials in the following format (Here are mine): PP P * AAAAAA AAAAAAA P P P P P P P P * Program Name: * Program Description: * Program Author: * Date Created: Change # P P P P P P P Since we have yet to cover variables in this class (they are introduced in chapter 2), you cannot use them to store the results of the above expression. To space down to the next line, use the escape character inside the quotes of your println statement. Also, to print the character "", use the Unicode character \u03C0 inside the quotes of your println statement. To concatenate a string and an arithmetic calculation, use the + concatenation sign. The result of integer division will only display the quotient and ignore the remainder. To display a more precise calculation, use, for example, 1.0 in the numerators above rather than 1 to generate a result with decimals. Also, be sure to use parentheses to ensure correct calculations. Sample console output: PP P Next, display the same output using the showMessageDialog method in the JOptionPane class. Be sure to place the following import statement after the package statement so that you have access to the showMessageDialog() method in the JOptionPane class: import javax.swing.JOptionPane; Here's an example statement: JOptionPane.showMessageDialog(null, "The sum of 1+2 = " + (1+2)); For your Java source file, you must include a program header documentation block, use block comments (/* */), and line comments (//). All programs that you write hereafter in this course must have a program header documentation block. If you do not include this, points will be taken off your assignment. Here is an example of a program documentation header block: P P Welcome to CSC108. (Your Name)'s approximation of it is: (space down one line) display the result of: 3.1427128427128426 Change Date OK Sample message dialog box output: Message i (3 + 4.0/(2*3*4) Lab01 - Approximating PI This approximates using the following Nilakantha series: = (3 + 4.0/(2*3*4) - 4.0/(4*5*6) + 4.0/ (6*7*8) - 4.0/ (8*9*10) + 4.0/(10*11*12) ... Patrick J Cassidy 08/24/2021 Programmer Name Welcome to CSC108. Patrick Cassidy's approximation of is: 4.0/ (4*5*6) + 4.0/ (6*7*8) - 4.0/(8*9*10) + 4.0/(10*11*12) X Patrick Cassidy's approximation of TT is: 3.1427128427128426 Description ***/ Zip the Lab01 project folder (Not just the Lab01.java source file). Then, rename the zipped file to "Your Name Lab01" and attach the file to the appropriate assignment in Blackboard under Assignments. You may want to refer to "How to save your Project" in BlackBoard. Once you have attached the file please make sure to click Submit. Approximating : The constant, "" is the ratio of the circumference of a circle to its diameter. It is known to be irrational and its decimal expansion therefore does not terminate or repeat. There are many ways to approximate . One way is to use the Nilakantha series: = (3 + 4.0/(2*3*4) - 4.0/ (4*5*6) + 4.0/ (6*7*8) - 4.0/ (8*9*10) + 4.0/(10*11*12) ...) Create a Java application in NetBeans called Lab01" and write a program called Lab01.java that displays the following to the console: Your initials in the following format (Here are mine): PP P * AAAAAA AAAAAAA P P P P P P P P * Program Name: * Program Description: * Program Author: * Date Created: Change # P P P P P P P Since we have yet to cover variables in this class (they are introduced in chapter 2), you cannot use them to store the results of the above expression. To space down to the next line, use the escape character inside the quotes of your println statement. Also, to print the character "", use the Unicode character \u03C0 inside the quotes of your println statement. To concatenate a string and an arithmetic calculation, use the + concatenation sign. The result of integer division will only display the quotient and ignore the remainder. To display a more precise calculation, use, for example, 1.0 in the numerators above rather than 1 to generate a result with decimals. Also, be sure to use parentheses to ensure correct calculations. Sample console output: PP P Next, display the same output using the showMessageDialog method in the JOptionPane class. Be sure to place the following import statement after the package statement so that you have access to the showMessageDialog() method in the JOptionPane class: import javax.swing.JOptionPane; Here's an example statement: JOptionPane.showMessageDialog(null, "The sum of 1+2 = " + (1+2)); For your Java source file, you must include a program header documentation block, use block comments (/* */), and line comments (//). All programs that you write hereafter in this course must have a program header documentation block. If you do not include this, points will be taken off your assignment. Here is an example of a program documentation header block: P P Welcome to CSC108. (Your Name)'s approximation of it is: (space down one line) display the result of: 3.1427128427128426 Change Date OK Sample message dialog box output: Message i (3 + 4.0/(2*3*4) Lab01 - Approximating PI This approximates using the following Nilakantha series: = (3 + 4.0/(2*3*4) - 4.0/(4*5*6) + 4.0/ (6*7*8) - 4.0/ (8*9*10) + 4.0/(10*11*12) ... Patrick J Cassidy 08/24/2021 Programmer Name Welcome to CSC108. Patrick Cassidy's approximation of is: 4.0/ (4*5*6) + 4.0/ (6*7*8) - 4.0/(8*9*10) + 4.0/(10*11*12) X Patrick Cassidy's approximation of TT is: 3.1427128427128426 Description ***/ Zip the Lab01 project folder (Not just the Lab01.java source file). Then, rename the zipped file to "Your Name Lab01" and attach the file to the appropriate assignment in Blackboard under Assignments. You may want to refer to "How to save your Project" in BlackBoard. Once you have attached the file please make sure to click Submit.
Expert Answer:
Answer rating: 100% (QA)
public class ValueOfPi public static void mainString args int iteration 0 double value 00 int ... View the full answer
Related Book For
Elementary Statistics A Step By Step Approach
ISBN: 9781259755330
10th Edition
Authors: Allan G. Bluman
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
reading the following article "How Truthful are memoirs? The Pulitzer Board should answer that question soon" As you read the article, reflect on the following questions what is a "factual memoir"?...
-
Define crowdsourcing and explain the different ways that companies can use an external crowd to do its work (e.g., the different types of crowdsourcing). Crowdsourcing is outsourcing tasks to...
-
Harper Corporation has the following portfolio of investments at December 31, 2014, that qualify and are accounted for using the fair value through other comprehensive income (FV-OIC) method: Early...
-
How much work does gravity do on a \(2.0-\mathrm{mg}\) raindrop as the drop falls to the ground from a cloud \(2000 \mathrm{~m}\) above the ground?
-
Income statements for Eldermon Sales Company follow. Analyze the inventory position at the end of each year as well as the profitability of inventory sales in each year. What conclusions would you...
-
(c) (10 pts) Suppose that the fund manager just shorted another portfolio worth of $10 million with a beta of 1.2, what position in the futures should the fund manager take now to make the combined...
-
The July transactions of Acorn Industries are described in Problem 7-2B. Problem 7-2B, Acorn Industries completes these transactions during July of the current year (the terms of all its credit sales...
-
Part 1: Create two problem statements that address two of the five topics you developed in assignment 4. Submit a draft of two 100-150-word problem statements that address those two topics. Be sure...
-
What are the two best practices related to Single Touch Payroll and 2 which relate to BAS preparation or lodgment, which ensure compliance with legislative requirements.
-
What payroll related tax is based on wages paid to employees and based on employer's payment history? Also explain federal income tax, unemployment taxes, Social Security taxes and income tax.
-
=Examine the nuanced trade-offs inherent in the execution of order-picking versus stock-replenishing functions within warehouse or distribution center operations, considering the intricate balance...
-
You purchased 1 5 0 shares in a real estate investment trust for $ 2 0 a share. The trust paid the following annual dividends: Year Dividend 1 $ 1 . 2 0 2 1 . 5 0 3 2 . 2 0 4 2 . 5 0 What...
-
Describe the most significant challenge(s) that the organization may face in the next five years. Explain with your own nearest building in process.
-
Fill in the blanks In an article exploring blood serum levels of vitamins and lung cancer risks (The New England Journal of Medicine), the mean serum level of Vitamin E in the control group was 11.9...
-
Currently, there are five concepts of food stands, including: hot dogs, soft pretzels, turkey legs, sandwich wraps, and funnel cakes. This approach will double the existing number of food stands...
-
Only 27% of U.S. adults get enough leisure time exercise to achieve cardiovascular fitness. Choose 3 adults at random. Find the probability that a. All 3 get enough daily exercise b. At least 1 of...
-
The frequency distribution shows the blood glucose levels (in milligrams per deciliter) for 50 patients at a medical facility. Construct a histogram, frequency polygon, and ogive for the data....
-
The sales in millions of dollars for a year of a sample of leading companies are shown. At α = 0.01, is there a significant difference in the means? Chocolate Candy Cereal Coffee 578...
-
Describe the link between the size of an organization and the formalization process.
-
Identify and describe the major features of the Strategic Management model.
-
Identify and describe the meaning of the term's formalization and informal.
CIMA C2 Financial Accounting Fundamentals 2006 Study Text 1st Edition - ISBN: 0751726486 - Free Book
Study smarter with the SolutionInn App