The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Can someone please help me with my errors to this program... I don't understand how to fix it. Thanks
Â
Â
package osu.cse1223;
import java.util.Scanner;
public class Project05 {
public static void main(String args) {
// TODO Auto-generated method stub
/*
* Project05.java
* This is a Guess-the-Number game that the user plays against the
computer. *
* @author Nick Pannell
* @version 20170211
*/
Scanner keyboard1 = new Scanner(System.in);
System.out.print("Enter a guess between 1 and 100: ");
int userSelection = keyboard1.nextInt();
int count = 0;
int compSelection = (int) (Math.random() * 100); while (userSelection != compSelection){
if(userSelection>100){
System.out.println("Your guess is our of
range. Pick a number between 1 and 100.");
System.out.print("Enter a guess between 1
and 100: ");
int userSelection = keyboard1.nextInt();
count ++;
} else if (userSelection > compSelection){
System.out.println("Your guess was too high.
Try again.");
System.out.print("Enter a guess between 1
and 100: ");
int userSelection = keyboard1.nextInt();
count ++;
} else {
System.out.println("Your guess was too low.
Try again.");
System.out.print("Enter a guess between 1
and 100: ");
int userSelection = keyboard1.nextInt();
count ++;
}
}
System.out.println("I had chosen " + compSelection + "
as the target number.");
System.out.println("You guessed it in " + count + "
tries.");
if (count =1){
System.out.println("That
} else if (count <= 4){
System.out.println("That
} else if (count <= 6){
System.out.println("That
} else if (count<= 7){
System.out.println("That
} else if (count <= 9){
System.out.println("That
} else { was lucky!");
was amazing!");
was good.");
was OK.");
was not very good."); } } } System.out.println("This just isn't your game.");