Big Java Late Objects
Big Java Late Objects
2nd Edition
ISBN: 9781119330455
Author: Horstmann
Publisher: WILEY
bartleby

Videos

Textbook Question
Book Icon
Chapter 4, Problem 12PP

The Buffon Needle Experiment. The following experiment was devised by Comte Georges-Louis Leclerc de Buffon (1707–1788), a French naturalist. A needle of length 1 inch is dropped onto paper that is ruled with lines 2 inches apart. If the needle drops onto a line, we count it as a hit. (See Figure 9.) Buffon discovered that the quotient tries/hits approximates π.

For the Buffon needle experiment, you must generate two random numbers: one to describe the starting position and one to describe the angle of the needle with the x-axis. Then you need to test whether the needle touches a grid line.

Generate the lower point of the needle. Its x-coordinate is irrelevant, and you may assume its y-coordinate ylow to be any random number between 0 and 2. The angle π between the needle and the x-axis can be any value between 0 degrees and 180 degrees (π radians). The upper end of the needle has y-coordinate

y h i g h = y l o w + sin α

The needle is a hit if yhigh is at least 2 as shown in Figure 10. Stop after 10,000 tries and print the quotient tries/hits. (This program is not suitable for computing the value of π. You need π in the computation of the angle.)

Chapter 4, Problem 12PP, The Buffon Needle Experiment. The following experiment was devised by Comte Georges-Louis Leclerc de , example  1

Figure 9

The Buffon Needle Experiment

Chapter 4, Problem 12PP, The Buffon Needle Experiment. The following experiment was devised by Comte Georges-Louis Leclerc de , example  2

Figure 10

A Hit in the Buffon Needle Experiment

Blurred answer
Students have asked these similar questions
Idiot’s Delight is a fairly simple game of solitaire, yet it is difficult to win. The goal is to draw all of the cards from the deck, and end up with no cards left in your hand. You will run through the deck of cards one time. Start by dealing 4 cards to your hand. You will always look at the last 4 cards in your hand. If the ranks of the “outer” pair (1st and 4th) are the same, discard all four cards. Otherwise, if the suits of the “inner” pair (2nd and 3rd) are the same, discard those 2 cards only. If you have less than 4 cards, draw enough to have 4 cards in your hand. If the deck is empty, the game is over. Your score will be the number of cards that remain in your hand. Like in golf, the lower the score the better. Create a new Python module in a file named “idiots_delight.py”. Add a function called deal_hand that creates a standard deck of cards, deals out a single hand of 4 cards and returns both the hand and the deck. Remember that for the last assignment, you created several…
IN JAVA Alice and Bob are playing a board game with a deck of nine cards. For each digit between 1 to 9, there is one card with that digit on it. Alice and Bob each draw two cards after shuffling the cards, and see the digits on their own cards without revealing the digits to each other. Then Alice gives her two cards to Bob. Bob sees the digits on Alice’s cards and lays all the four cards on the table in increasing order by the digits. Cards are laid facing down. Bob tells Alice the positions of her two cards. The goal of Alice is to guess the digits on Bob’s two cards. Can Alice uniquely determine these two digits and guess them correctly? Input The input has two integers p,q (1≤p<q≤9) on the first line, giving the digits on Alice’s cards. The next line has a string containing two ‘A’s and two ‘B’s, giving the positions of Alice’s and Bob’s cards on the table. It is guaranteed that Bob correctly sorts the cards and gives the correct positions of Alice’s cards. Output If Alice can…
Java - Encapsulation A rectangle can be formed given two points, the top left point and the bottom right point. Assuming that the top left corner of the console is point (0, 0), the bottom right corner of the console is point (MAX, MAX) and given two points (all “x” and “y” coordinates are positive), you should be able to draw the rectangle in the correct location, determine if it is a square or a rectangle, and compute for its area, perimeter and center point. To be able to do this, you should create a class Point (that has an x-coordinate and a y-coordinate). Also, create another class called Rectangle. The Rectangle should have 2 points, the top left and the bottom right. You should also implement the following methods for the Rectangle: display() - draws the rectangle on the console based on the samplearea() - computes and returns the area of a given rectangleperimeter() - computes and returns the perimeter of a given rectanglecenterPoint() - computes and returns the center point…

Chapter 4 Solutions

Big Java Late Objects

Ch. 4.3 - Write the for loop of the InvestmentTable.java...Ch. 4.3 - How many numbers does this loop print? for (int n...Ch. 4.3 - Write a for loop that prints all even numbers...Ch. 4.3 - Write a for loop that computes the sum of the...Ch. 4.3 - How would you modify the for loop of the...Ch. 4.4 - Prob. 16SCCh. 4.4 - Rewrite the input check do loop using a while loop...Ch. 4.4 - Suppose Java didnt have a do loop. Could you...Ch. 4.4 - Write a do loop that reads integers and computes...Ch. 4.4 - Write a do loop that reads integers and computes...Ch. 4.5 - What does the SentinelDemo.java program print when...Ch. 4.5 - Why does the SentinelDemo.java program have to...Ch. 4.5 - What would happen if the declaration of the salary...Ch. 4.5 - In the last example of this section, we prompt the...Ch. 4.5 - Prob. 25SCCh. 4.6 - Prob. 26SCCh. 4.6 - Google has a simple interface for converting...Ch. 4.6 - Consider a modification of the program in Self...Ch. 4.6 - Prob. 29SCCh. 4.6 - Produce a storyboard for a program that compares...Ch. 4.7 - What total is computed when no user input is...Ch. 4.7 - Prob. 32SCCh. 4.7 - What are the values of position and ch when no...Ch. 4.7 - Prob. 34SCCh. 4.7 - Prob. 35SCCh. 4.7 - Prob. 36SCCh. 4.8 - Why is there a statement System.out.println(); in...Ch. 4.8 - How would you change the program to display all...Ch. 4.8 - Prob. 39SCCh. 4.8 - What do the following nested loops display? for...Ch. 4.8 - Prob. 41SCCh. 4.9 - Prob. 42SCCh. 4.9 - You need to write a program for DNA analysis that...Ch. 4.9 - Prob. 44SCCh. 4.9 - Consider the task of finding numbers in a string....Ch. 4.10 - How do you simulate a coin toss with the...Ch. 4.10 - How do you simulate the picking of a random...Ch. 4.10 - Why does the loop body in Dice.java call...Ch. 4.10 - Prob. 49SCCh. 4.10 - Prob. 50SCCh. 4 - Given the variables String stars = ""; String...Ch. 4 - What do these loops print? a. int i = 0; int j =...Ch. 4 - What do these code snippets print? a. int result =...Ch. 4 - Write awhile loop that prints a. All squares less...Ch. 4 - Write a loop that computes a. The sum of all even...Ch. 4 - Provide trace tables for these loops. a. int i =...Ch. 4 - What do these loops print? a. for (int i = 1; i ...Ch. 4 - What is an infinite loop? On your computer, how...Ch. 4 - Write a program trace for the pseudocode in...Ch. 4 - What is an off-by-one error? Give an example from...Ch. 4 - What is a sentinel value? Give a simple rule when...Ch. 4 - Which loop statements does Java support? Give...Ch. 4 - How many iterations do the following loops carry...Ch. 4 - Write pseudocode for a program that prints a...Ch. 4 - Prob. 15RECh. 4 - Write pseudocode for a program that reads a...Ch. 4 - Write pseudocode for a program that reads a...Ch. 4 - Rewrite the following for loop into a while loop....Ch. 4 - Rewrite the following do loop into a while loop....Ch. 4 - Provide trace tables of the following loops. a....Ch. 4 - What do the following loops print? Work out the...Ch. 4 - What do the following program segments print? Find...Ch. 4 - Prob. 23RECh. 4 - Add a storyboard panel for the conversion program...Ch. 4 - In Section 4.6, we decided to show users a list of...Ch. 4 - Change the storyboards in Section 4.6 to support a...Ch. 4 - Draw a flowchart for a program that carries out...Ch. 4 - In Section 4.7.5, the code for finding the largest...Ch. 4 - What are nested loops? Give an example where a...Ch. 4 - The nested loops for (int 1 = 1; 1 = height; i++)...Ch. 4 - Suppose you design an educational game to teach...Ch. 4 - In a travel simulation, Harry will visit one of...Ch. 4 - Write programs with loops that compute a. The sum...Ch. 4 - Write programs that read a sequence of integer...Ch. 4 - Write programs that read a line of input as a...Ch. 4 - Complete the program in How To 4.1 on page 171....Ch. 4 - Write a program that reads a set of floating-point...Ch. 4 - Translate the following pseudocode for finding the...Ch. 4 - Translate the following pseudocode for randomly...Ch. 4 - Write a program that reads a word and prints each...Ch. 4 - Write a program that reads a word and prints the...Ch. 4 - Write a program that reads a word and prints the...Ch. 4 - Write a program that reads a word and prints the...Ch. 4 - Write a program that reads a word and prints all...Ch. 4 - Write a program that reads a string and prints the...Ch. 4 - Write a program that reads a sequence of words and...Ch. 4 - Write a program that prints all powers of 2 from...Ch. 4 - Write a program that reads a number and prints all...Ch. 4 - Prob. 18PECh. 4 - Write a program that reads an integer and...Ch. 4 - Write a program that reads an integer and...Ch. 4 - Write a program to plot the following face.Ch. 4 - Write a graphical application that displays a...Ch. 4 - Enhance Worked Example 4.1 to check that the...Ch. 4 - Mean and standard deviation. Write a program that...Ch. 4 - The Fibonacci numbers are defined by the sequence...Ch. 4 - Factoring of integers. Write a program that asks...Ch. 4 - Prime numbers. Write a program that prompts the...Ch. 4 - The game of Nim. This is a well-known game with a...Ch. 4 - The Drunkards Walk. A drunkard in a grid of...Ch. 4 - The Monty Hall Paradox. Marilyn vos Savant...Ch. 4 - A simple random generator is obtained by the...Ch. 4 - The Buffon Needle Experiment. The following...Ch. 4 - In the 17th century, the discipline of probability...Ch. 4 - Write a program that reads an initial investment...Ch. 4 - Currency conversion. Write a program that first...Ch. 4 - Write a program that first asks the user to type...Ch. 4 - Your company has shares of stock it would like to...Ch. 4 - Write an application to pre-sell a limited number...Ch. 4 - You need to control the number of people who can...Ch. 4 - Credit Card Number Check. The last digit of a...Ch. 4 - In a predator-prey simulation, you compute the...Ch. 4 - Projectile flight. Suppose a cannonball is...Ch. 4 - Radioactive decay of radioactive materials can be...Ch. 4 - The photo at left shows an electric device called...Ch. 4 - Write a graphical application that draws a spiral,...Ch. 4 - Prob. 28PPCh. 4 - Draw a picture of the four-leaved rose whose...
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY