Having a few problems after recently starting Eclipse Java -


hello have start learning java coding on eclipse , have made few simple things.

i trying make basic game random number 1-100 chosen program , have try , pick it, program telling whether higher or lower. i've encountered few problems.

import java.util.scanner; import java.util.*;  public class numbergame {      /**number guessing game       * calculates random number , has player guess      */      public static void main (string[] args) {     int mynumber, guess;      system.out.println("what guess?");     scanner guessscanner = new scanner(system.in);     random mynumber = new random();      int number = randomnumber.nextint(100);      guess = guessscanner;     if (guess<mynumber) {         system.out.println ("the number less");     }     if (guess>mynumber) {         system.out.println ("your guess more");      }     else{         if (guess==mynumber)             system.out.println ("your number correct");     }     } } 

this have done far,

the following lines not working not sure how fix them:

random mynumber = new random();   int number = randomnumber.nextint(100);   guess = guessscanner;  if (guess<mynumber) { 

could please have advice of how fix these? , how make program record umber of guesses?

change

 guess = guessscanner 

to

 guess = guessscanner.nextint(); 

you willing take user input int. guess = guessscanner assigning int scanner. wrong.

and change

random randomnumber = new random();  

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -