subject
Computers and Technology, 10.05.2021 18:10 fatty18

The project downloaded contains a package (folder) named Q1 within the src folder. Inside Q1 is a Java class named Questions. The purpose of Question 1 is to examine your understanding of loops and branching conditions. You should implement all of your code for this question in the main method of the Questioni class. While significant detail is provided below to be sure you undertand what is required, please note that the amount of code required to solve this question (Parts a-c) is less than 10 lines (total). In the Question1 class, you are given a line of code that generates a random number between 0 and 1. Math. random(): //generates number between 0 and 1 val You are to create a loop which, in each iteration, generates a new random value, assigns it to val using the line provided and checks to see if that val is greater than 0.5. If val is greater than 0.5, a variable named counter should be incremented. The loop should continue this process (generate random value, check if it is greater than 0.5) until a total of three random numbers generated are greater than 0.5 (values do not have to be consecutive). You should also use the variable named numIterations, which is included for you, to track how many iterations of your loop were required for you to generate three random numbers greater than 0.5. A printin() statement is included for you that displays the value of numlterations. As an example of how the program should behave, if the following sequence of random numbers are randomly generated from your loop
0.3, 0.7,0.2, 0.6,0.9
then numIterations would equal 5 (the third value greater than 0.5 occured on the fifth iteration).
If
0.6, 0.8, 0.75
was the random sequence of numbers generated by your loop, then numlterations would equal 3 (the third value greater than 0.5 occured on the third iteration).
These are two examples to illustrate the scenario given in Question 1. Since at each iteration of your loop the number generated is random, the value of numIterations that your program observes may be any value greater than or equal to 3. Note that your program does not need to print out each of the random values that it generates. The steps to solve Question 2 are broken down as follows.
a. Implement a branching condition that increases the variable counter by 1 if val is larger than 0.5 1
b. Add a loop around the code created in Part a that continues until counter equals 3.
c. Use the variable numlterations to count how many times your loop iterates.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 18:10
Assume that to_the_power_of is a function that expects two int parameters and returns the value of the first parameter raised to the power of the second parameter. write a statement that calls to_the_power_of to compute the value of cube_side raised to the power of 3 and that associates this value with cube_volume.
Answers: 1
question
Computers and Technology, 23.06.2019 01:50
Create a class named majors that includes an enumeration for the six majors offered by a college as follows: acc, chem, cis, eng, his, phys. display the enumeration values for the user, then prompt the user to enter a major. display the college division in which the major falls. acc and cis are in the business division, chem and phys are in the science division, and eng and his are in the humanities division. save the file as majors.java.
Answers: 2
question
Computers and Technology, 23.06.2019 11:00
This chapter lists many ways in which becoming computer literate is beneficial. think about what your life will be like once you’re started in your career. what areas of computing will be most important for you to understand? how would an understanding of computer hardware and software you in working from home, working with groups in other countries and contributing your talents.
Answers: 1
question
Computers and Technology, 24.06.2019 13:00
In a heat transfer course, we can derive the equation for the temperature distribution in a flat rectangular plate. in this example, we will look at a plate at steadystate with three sides being held at t1, and one side held at t2. the temperature for any location on the plate, t(x,y), can be calculated by where create a function (prob3_5) that will take inputs of vectors x and y in feet, scalar n, scalars l and w in feet and scalars t1 and t2 in degrees fahrenheit. it will output a matrix t which is the temperature of each x and y locations. t will have the number of columns equal to the number of elements in x and rows equal to the number of elements in y. though this can be done without loops (perhaps more efficiently), your program must use a nested loop.
Answers: 2
You know the right answer?
The project downloaded contains a package (folder) named Q1 within the src folder. Inside Q1 is a Ja...
Questions
question
Mathematics, 03.05.2021 22:50
question
Social Studies, 03.05.2021 22:50
Questions on the website: 13722360