Jump to content

java code help pls

bomberblyat
Go to solution Solved by Strayuru,

Change:

String first = lukija.nextLine();

to

int first = lukija.nextInt();

and

if(first.equals(second)) {

to

if(first == second) {

And then try again, I haven't tested it.

public class Guessinggame {
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    { Random rand = new Random();
    Scanner lukija = new Scanner(System.in);
        int second  = 1;
        System.out.println("Guess the number 1 - 100");
            String first = lukija.nextLine();
        if(first.equals(second)) {
            System.out.println("Correc ");
        }
        else{
         System.out.println("Wrong ");
        }
    
        System.out.println(second);
        
        
    }
    
}

its not work

Link to comment
Share on other sites

Link to post
Share on other sites

Change:

String first = lukija.nextLine();

to

int first = lukija.nextInt();

and

if(first.equals(second)) {

to

if(first == second) {

And then try again, I haven't tested it.

Bespoke Software Engineer

 

Laptop: MacBook Air (13-inch, Early 2015) - 8GB RAM - Intel Core i5 1.6GHz - Intel HD Graphics 6000 1536 MB

DesktopGAMEMAX Onyx - AMD FX6300 Black Edition 6 Core (Overclocked to 4.1GHz) - GIGABYTE NVIDIA GTX 1050Ti Overclocked - MSI NVIDIA GTX 750Ti Gaming 1085MHz - HyperX Savage 8 GB 1866 MHz DDR3 - MSI 970 Gaming - Corsair CP-9020015-UK - Kingston SSDNow UV400 120 GB Solid State Drive

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Strayuru said:

Change:


String first = lukija.nextLine();

to


int first = lukija.nextInt();

and


if(first.equals(second)) {

to


if(first == second) {

And then try again, I haven't tested it.

thx bob

Link to comment
Share on other sites

Link to post
Share on other sites

np joe

Bespoke Software Engineer

 

Laptop: MacBook Air (13-inch, Early 2015) - 8GB RAM - Intel Core i5 1.6GHz - Intel HD Graphics 6000 1536 MB

DesktopGAMEMAX Onyx - AMD FX6300 Black Edition 6 Core (Overclocked to 4.1GHz) - GIGABYTE NVIDIA GTX 1050Ti Overclocked - MSI NVIDIA GTX 750Ti Gaming 1085MHz - HyperX Savage 8 GB 1866 MHz DDR3 - MSI 970 Gaming - Corsair CP-9020015-UK - Kingston SSDNow UV400 120 GB Solid State Drive

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×