subject

What does this program do?
what is the program output if the user enters 1 when prompted for the number of points?
how would your answer to the above question change if the test in line 15 used < = rather than < ?
print the homework or copy and paste the code below in your homework. draw a box around each statement, and underline each expression, in the code. (even though technically an assignment in java is an expression, do not underline entire assignments.)
the random component provides a pseudo-random number generator that generates numbers uniformly distributed in the [0.0,1.0) interval; the method call rnd. nextdouble() returns a pseudo-random number in the [0.0,1.0) interval. (in case you're not familiar with the notation here, [0.0,1.0) denotes an interval consisting of all real numbers between 0.0 inclusive and 1.0 exclusive, i. e., the set of all values x satisfying 0.0 ≤ x < 1.0.)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
public static void main(string[] args) {
simplereader input = new simplereader1l();
simplewriter output = new simplewriter1l();
output. print("number of points: ");
int n = input. nextinteger();
int ptsininterval = 0, ptsinsubinterval = 0;
random rnd = new random1l();
while (ptsininterval < n) {
double x = rnd. nextdouble();
ptsininterval++;
if (x < 0.5) {
ptsinsubinterval++;
}
}
double estimate = (100.0 * ptsinsubinterval) / ptsininterval;
output. println("estimate of percentage: " + estimate + "%");
input. close();
output. close();
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 18:10
For each of the following claims, determine whether they are true or false. justify your determination (show your work). if the claim is false, state the correct asymptotic relationship as o, θ, or ω. unless otherwise specified, lg is log2.(a) (b) (c) (d) (e) (f) (g) (h) (i) (j)n+1 =22n =2n =1 =ln2 n =n2 +2n−4 =33n = 2n+1 =√n = 10100 =o(n4) o(2n)θ(2n+7 ) o(1/n)θ(lg2 n) ω(n2 )θ(9n ) θ(2n lg n )o(lg n) θ(1)
Answers: 1
question
Computers and Technology, 23.06.2019 18:00
Which finger presses the h key on the keyboard? index finger on the left hand pinky finger on the right hand index finger on the right hand thumb on the left hand
Answers: 1
question
Computers and Technology, 24.06.2019 02:00
What is a loop? a. a collection of function definitions at the top of a program b. a line of code that defines a variable and assigns it a value c. a program that opens the turtle graphics window d. a block of code that repeats a specific number of times
Answers: 1
question
Computers and Technology, 24.06.2019 07:00
You are most likely to automatically encode information about
Answers: 1
You know the right answer?
What does this program do?
what is the program output if the user enters 1 when prompted for...
Questions
question
English, 09.12.2020 05:10
question
Social Studies, 09.12.2020 05:10
question
English, 09.12.2020 05:10
question
Arts, 09.12.2020 05:10
Questions on the website: 13722363