subject

Write a program that generates a random number and asks the user to guess what the number is. if the user's guess is higher than the random number, the program should display "too high, try again." if the user's guess is lower than the random number, the program should display "too low, try again." the program should use a loop that repeats until the user correctly guesses the random number. you shall also keep a count of the number of guesses that the user makes. when the user correctly guesses the random number, the program should display the number of guesses. now add another loop to ask the user if he or she wishes to play the guessing game again. if so, the loop should repeat, otherwise it should terminate. so far, this is what my program looks like, any or suggestions would be greatly appreciated! // this program generates a random number and askes the user to guess what the number isimport java. util. scanner; import java. util. random; public class guessinggame{public static void main(string [] args){//create a scanner object to read from the keyboardscanner kb = new scanner(system. in); //create a random objectrandom rand = new random(); //identifier declarationsint num = rand. nextint(100) + 1; int guess = 0; int count = 0; int guesses = 0; do{system. out. println("guess what number i have (1-100)? "); guess = kb. nextint(); guesses ++; if(num > guess) {system. out. println("too high, try again."); } else if(num < guess) {system. out. println("too low, try again."); } else {system. out. println("you're right, the number is" + num); system. out. println("you guessed" + guesses + "times"); }}while(guess! =num); }}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 21:00, sarah192002
You should hand write your references on your resume.
Answers: 1
image
Computers and Technology, 22.06.2019 18:30, leannhb3162
Which of these options are the correct sequence of actions for content to be copied and pasted? select content, click the copy button, click the paste button, and move the insertion point to where the content needs to be inserted. click the copy button, select the content, move the insertion point to where the content needs to be inserted, and click the paste button. select the content, click the copy button, move the insertion point to where the content needs to be inserted, and click the paste button. select the content, move the insertion point to where the content needs to be inserted, click the copy button, and click the paste button.
Answers: 3
image
Computers and Technology, 23.06.2019 09:50, tatumleigh04
Allison and her group have completed the data entry for their spreadsheet project. they are in the process of formatting the data to make it easier to read and understand. the title is located in cell a5. the group has decided to merge cells a3: a7 to attempt to center the title over the data. after the merge, allison points out that it is not centered and looks bad. where would the title appear if allison unmerged the cells in an attempt to fix the title problem?
Answers: 2
image
Computers and Technology, 24.06.2019 11:40, girdwood6678
100 pts. first person gets brainliest
Answers: 2
You know the right answer?
Write a program that generates a random number and asks the user to guess what the number is. if the...

Questions in other subjects: