Question

In: Computer Science

Design a program using Raptor Flowcharts that tests your ESP, or extrasensory perception. The program will...

Design a program using Raptor Flowcharts that tests your ESP, or extrasensory perception. The program will randomly pick a color from Red, Green, Blue, Orange, Yellow, and Purple, and you will be asked to predict the program's selection before it is revealed. The program should ask the user to enter the color the computer has selected. The program should ensure user enters only one of the six colors. After user has entered his or her guess, the program should display the name of the randomly selected color. The program should repeat this 10 times and then display the number of times the user correctly guessed the selected color.  

Solutions

Expert Solution

static List<String> choices = Lists.newArrayList("red", "green", "blue", "orange", "yellow", "violet");

public ststic void main(String[] args)

{

int correctGuesses = 0;

String input;

Scanner Keyboard = new Scanner(System.in);

//join list for display

String colors = String.join(", ", choices);

//play the game for 10 rounds.

for(int round = 1;round<=10; round++)

{

Sysyem.out.print("my predition of the color is " + colors + ":");

input = keyboard.next();

while(!isValidChoice(input)) {

System.out.print("Please enter " + colors+ ":");

input = keyboard.next();

}

if(computerChoice().equalsIgnoreCase(input))

{

correctGuesses ++;

}

}

Keyboard.close();

System.out.println("Number of correct guesses: " +correctGuesses);

}

static String computerChoice()

{

Random random = new Random();

OptionalInt computerChoice = random.ints(0, choices.size() -1).findFirst();

return choices.get(computerChoice.getAsInt());

}

static boolean isValidChoice(String input)

{

java.util.Optional<String> val = choices.stream().filter(e -> e.equals(input.toLowerCase())).findAny();

return val.isPresent();

}


Related Solutions

Design a program using Raptor Flowcharts that tests your ESP, or extrasensory perception. The program will...
Design a program using Raptor Flowcharts that tests your ESP, or extrasensory perception. The program will randomly pick a color from Red, Green, Blue, Orange, Yellow, and Purple, and you will be asked to predict the program's selection before it is revealed. The program should ask the user to enter the color the computer has selected. The program should ensure user enters only one of the six colors. After user has entered his or her guess, the program should display...
Task: Craps is a popular game played in casinos. Design a program using Raptor Flowcharts to...
Task: Craps is a popular game played in casinos. Design a program using Raptor Flowcharts to play a variation of the game, as follows: Roll two dice. Each dice has six faces representing values 1, 2, 3, 4, 5, and 6, respectively. Check the sum of the two dice. If the sum is 2, 3, or 12(called craps), you loose; if the sum is 7 or 11(called natural), you win; if the sum is another value(i.e., 4, 5, 6, 8,...
In an experiment in extrasensory perception (ESP), a subject in one room is asked to state...
In an experiment in extrasensory perception (ESP), a subject in one room is asked to state the color (red or blue) of a card chosen from a deck of 50 well-shuffled cards by an individual in another room. It is unknown to the subject how many red or blue cards are in the deck. a.) What are your null and alternate hypotheses in this case? b.) If the subject identifies 32 cards correctly, determine the chances of each hypothesis being...
In a test for ESP (extrasensory perception), the experimenter looks at cards that are hidden from...
In a test for ESP (extrasensory perception), the experimenter looks at cards that are hidden from the subject. Each card contains either a star, a circle, a wave, or a square. As the experimenter looks at each of 20 cards in turn, the subject names the shape on the card. (a) (3pts) Suppose a subject simply guesses the shape on each card, independently from card to card. What is the probability that he guesses correctly the shape on exactly 5...
1. A man claims to have extrasensory perception (ESP). As a test, a fair coin is...
1. A man claims to have extrasensory perception (ESP). As a test, a fair coin is flipped 28 times, and the man is asked to predict the outcome in advance. He gets 22 out of 28 correct. What is the probability that he would have done at least this well if he had no ESP? Probability = 2. A careless university student leaves her iClicker device behind with probability 1/4 each time she attends a class. She sets out with...
(1 point) A man claims to have extrasensory perception (ESP). As a test, a fair coin...
(1 point) A man claims to have extrasensory perception (ESP). As a test, a fair coin is flipped 3030 times, and the man is asked to predict the outcome in advance. He gets 2424 out of 3030 correct. What is the probability that he would have done at least this well if he had no ESP? Hint: If he has no ESP, then he's just randomly guessing, right? If he is randomly guessing, what should you use as pp, the...
Subjects tested for ESP (extrasensory perception) are presented one of five types of cards, “circle”, “plus”,”wavy...
Subjects tested for ESP (extrasensory perception) are presented one of five types of cards, “circle”, “plus”,”wavy lines”, “square” and “star”. The type of card is hidden from the subject, and the subject attempts to use “psychic powers” to determine the card. (https://psychicscience.org/esp3) The test we are conducting is ?0 : ? = 0.20 vs. ??: ? ≠ 0.20 . Note that a person without ESP (that is, a “random guesser”) would be characterized at having ? = 0.20. Someone with...
Discuss with the class the importance of program design (using pseudocode and/or flowcharts) when designing programs...
Discuss with the class the importance of program design (using pseudocode and/or flowcharts) when designing programs utilizing selection structures.
Must be done with the Program Raptor Program #2 - Area of Shapes Design a superclass...
Must be done with the Program Raptor Program #2 - Area of Shapes Design a superclass called Shape that contains two functions—getVolume() and getInput(). The getVolume and getInput functions in the Shape class will simply return 0, you will derive from them in your subclasses mentioned below. Define 3 subclasses of the Shape class—Sphere, Cube, and Cone. The sphere class will need a radius field, the cube class will need a length field, and the cone class will need radius...
Using RAPTOR create a program that allows the user to input a list of first names...
Using RAPTOR create a program that allows the user to input a list of first names in on array and last names into a parallel array. Input should be terminated when the user enters a sentinel character. the output should be a list of email address where the address is of the following form: [email protected]
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT