0

HI,
I am new to java programming. So, while practicing some java programming. I got a very strange logical error.

Does'nt matter what the user enters, the programm always returs the result as true.
Please, tell where I am stuck:

I will be positing my code here:

import java.util.Random;
import java.util.Scanner;

public class Tanmay {

    public static void main(String... asd) {
        int b = 0;
        Random randomGenerator = new Random();
        int a = randomGenerator.nextInt(10);
        System.out.println(a);
        network n = new network();
        n.setter(a);

        Scanner d = new Scanner(System.in);

        int c;
        System.out.print("\nplease enter your guess!\n");
        c = d.nextInt();
        n.getter(a);
        System.out.print(c + "\n");
        n.checker();


    }
}
_________________________________________

//the network class:


public class network {

    private int input=0;
    private int checker=1;
public boolean again = false;

    public void setter(int a) {
        input = a;
    }

    public void getter(int a) {
        checker = a;

    }
public void checker(){
    if(input==checker)
System.out.println("its true ");
    else 
        System.out.println("its false");
}


    }

_________________________

I know, they are many unused variables. Actually when the program was not working. I tried to check the errors, by making the code more simple. That is why I have so many unused variables.

please help out the noob, with this problem..

THank you in advance.

2
Contributors
2
Replies
17
Views
4 Years
Discussion Span
Last Post by tanmay.majumdar2
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.