Computers and Technology
Computers and Technology, 02.12.2019 18:31, ramos1997

Write a program that lets the user play the game of rock, paper, scissors against the computer. the program should work as follows.

when the program begins, a random number in the range of 1 through 3 is generated. if the number is 1, then the computer has chosen rock. if the number is 2, then the computer has chosen paper. if the number is 3, then the computer has chosen scissors. don’t display the computer’s choice yet.

the user enters his or her choice of "rock", "paper", or "scissors" at the keyboard. 3. the computer’s choice is displayed.

a winner is selected according to the following rules:

• if one player chooses rock and the other player chooses scissors, then rock wins. the rock smashes the scissors.

• if one player chooses scissors and the other player chooses paper, then scissors wins. scissors cuts paper.

• if one player chooses paper and the other player chooses rock, then paper wins. paper wraps rock.

• if both players make the same choice, the game must be played again to determine the winner. be sure to divide the program into methods that perform each major task. here is the description of the methods you should implement:

• public static string computerchoice() – this method will return the computer’s choice of "rock", "paper", or "scissors". • public static string userchoice () – this method will return the user’s choice of "rock", "paper", or "scissors" after validating the user’s choice using isvalidchoice method.

• public static boolean isvalidchoice (string choice) – this method will take a string holding the user’s choice as parameter and return true if the choice is valid ("rock", "paper", or "scissors"), false otherwise. be sure that the comparison is not case sensitive.

• public static void determinewinner(string computer, string user)– this method will take both the choices as parameter and display the winner.

call the method isvalidchoice() in a while loop in the userchoice() method to verify that the choice that user enters must be "rock", "paper", or "scissors". if invalid string is input, isvalidchoice()will return false and the program should ask for new input until the valid input is given.

the user is allowed to play the game as often as desired .

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 15:00, nika0001
When designing content as part of your content marketing strategy, what does the "think" stage represent in the "see, think, do, care" framework?
Answers: 3
image
Computers and Technology, 22.06.2019 16:20, mandy9386
Consider the following statements, then select one of the answers below: the signal() function shown below registers "sig_handler()" as the signal handler function for the sigkill signal, without the complexity of using when the sigkill signal is sent to a process running this code, by a user typing "kill -kill ", where the correct process id is used for to target the process, sig_handler() will be executed.
Answers: 1
image
Computers and Technology, 22.06.2019 19:50, rosyposy43
Write a car class having two private member variables called tank and speed. write public methods called pumpgas and gofast. the method pumpgas gets an integer for gas that must be pumped. that value needs to be added to tank (no more than 20 gallons). it must return the amount of gas that is purchased ($4 per gallon). the method gofast should increase the speed by 5 each time it is called. write a constructor for the above class that initialized both variables to zero. write a tostring to display both the tank and speed when the car is printed. modify the car class to implement the interface comparable and an interface called carinter having the public methods in carinter. write the main program to create an array of size 5 of type car. create 5 car objects having each location of the array to refer to one of the cars. test the pumpgas, gofast, equals method on the array items. write an enhanced loop to print all the car values (using a tostring written last time).write a generic method to find the minimum of four items. pass int, double, char, string and car objects to test this method.
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, Princessirisperez0
Given a link with a maximum transmission rate of 32.8 mbps. only two computers, x and y, wish to transmit starting at time t = 0 seconds. computer x sends filex (4 mib) and computer y sends filey (244 kib), both starting at time t = 0. statistical multiplexing is used, with details as follows packet payload size = 1000 bytes packet header size = 24 bytes (overhead) ignore processing and queueing delays assume partial packets (packets consisting of less than 1000 bytes of data) are padded so that they are the same size as full packets. assume continuous alternating-packet transmission. computer x gets the transmission medium first. at what time (t = ? ) would filey finish transmitting? give answer in milliseconds, without units, and round to one decimal places (e. g. for an answer of 0.013777 seconds you would enter "13.8" without the quotes)
Answers: 3
Do you know the correct answer?
Write a program that lets the user play the game of rock, paper, scissors against the computer. the...

Questions in other subjects: