Question: Please make simple program were only on beginner loops and methods A Psychology experiment is conducted in two stages. In the first stage, each participant
Please make simple program were only on beginner loops and methods
A Psychology experiment is conducted in two stages. In the first stage, each participant is asked
questions. The number of correct answers to these questions is considered as the initial score of the
participant. If the initial score is greater than or equal to the experiment proceeds with stage ;
otherwise it proceeds with stage B In stage A the participant's behavioral score a value between
to both inclusive is added to the initial score. If the sum is greater than or equal to
the participant is selected. Otherwise, the participant is not selected. In stage B the participant
is asked another questions. The number of correct answers to these questions is considered as
the second score. Now, the participant's behavioral score is added to the maximum of the initial
score and the second score. If this sum is greater than or equal to the participant is selected.
Otherwise, the participant is not selected.
Write a Java program that determines whether a participant is selected based on the scores from the
experiment.
Programming requirements
In addition to the main method, you must write two methods, one for stage A calculation name
it as stageA and the other for stage B calculation name it as stageB Both methods should
be called from the main method.
In the main method, you must read the initial score from input. Make sure to validate the initial
score to be in the range to assume that the participant answers at least one question
correctly If the user enters an incorrect value, force the user to enter the correct value you
may need to use a while loop for this
The method stageA must be written as a nonvoid method which accepts the initial score as
input and must return the final score after adding the initial score and the behavioral score.
The behavioral score must be generated as a random integer. Use the following expression to
generate the behavioral score
Math.random ;
Notice that the behavioral score is a double value and hence the final score is a double too.
The method stageB must be written as a nonvoid method which accepts the initial score and
scan the Scanner object that was created by the main method as inputs and must return
the final score after adding the maximum of the initial score and the second score, with the
behavioral score. The second score must be read from the input inside this method The
second score must be validated in the same way as the initial score. The behavioral score must
be generated as a random integer as mentioned in the previous step.
Both methods stageA and stageB must print the initial score and the final score. Method
stageB must also print the second score as well.
The main method must print the message indicating whether or not the participant is selected.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
