I am new to Java. I am looking for help with homework. I will not publish the complete code that I did initially, but I do not think that this will help me learn it.
I have a program that works with classes. I have a class that will test the selection and a class that has my setters and getters, and the class that the professor encoded using the program I / O (this is the book addres).
I have an expression in my main form that states
//create new scanner Scanner ip = new Scanner(System.in); System.out.println(); int menuNumber = Validator.getInt(ip, "Enter menu number: ", 1, 3); if (menuNumber = 1) { //print address book } else if (menuNumber = 2) { // get input from user } else { Exit }
If you look at the if if if (menuNumber = 1) , I get a red line that tells me that I cannot convert int to boolean. I thought the answer was if (menuNumber.equals(1)) , but that also gave me a similar error.
I'm not 100% on what I can do to fix this, so I wanted to ask for help. Do I need to convert my entry to a string? Now my validator looks something like this:
if (int < 1) print "Error entry must be 1, 2 or 3) else if (int > 3) print "error entry must 1, 2, or 3) else print "invalid entry"
If I convert my main to a string instead of int wont, should I change all this too?
Thanks again for helping me, I have not been so great, and I want to get a good piece of the job knocked out.
source share