I am creating an example login app. For some reason when I call the method checkFinal in my main method it is giving me an error. It says that it needs to call the booleans which check the username and the password. Which I did. It says that they can not be passed through. I do not know if this is an pass by value or a pass by reference issue. I have all of the other code working.
import java.util.Scanner;
public class program {
private static Scanner a;
private static String inputusername;
private static Scanner b;
private static String inputpassword;
private static String validusername;
private static String validpassword;
public static void main(String[] args) {
greeting();
questiona();
questionb();
username();
password();
checkOne(validusername, inputusername);
checkTwo(validpassword, inputpassword);
checkFinal(usernamecheck, passwordcheck);
}
public static void greeting() {
System.out.println("Hello!");
System.out.println("Note: All Things Are Case Sensitive!");
}
public static String questiona() {
System.out.println("What Is Your Username?");
a = new Scanner(System.in);
inputusername = a.next();
return inputusername;
}
public static String questionb() {
System.out.println("What Is Your Password");
b = new Scanner(System.in);
inputpassword = b.next();
return inputpassword;
}
public static String username() {
validusername = "username";
return validusername;
}
public static String password() {
validpassword = "password";
return validusername;
}
public static boolean checkOne(String validusername, String inputusername) {
boolean usernamecheck = false;
if (validusername == inputusername) {
usernamecheck = true;
}
return usernamecheck;
}
public static boolean checkTwo(String validpassword, String inputpassword) {
boolean passwordcheck = false;
if (validpassword == inputpassword) {
passwordcheck = true;
}
return passwordcheck;
}
public static boolean checkFinal(boolean usernamecheck, boolean passwordcheck) {
boolean checkFinal = false;
if (usernamecheck == true && passwordcheck == true) {
checkFinal = true;
} else {
checkFinal = false;
}
return checkFinal;
}
public static void compile(String[] args) {
}
public static void server(String[] args) {
}
}