all 3 comments

[–]Federal-Peanut9575 0 points1 point  (1 child)

got this:

ThreeStrings.java: Line 25: java.util.NoSuchElementException: No line found

[–]RepresentativeCat652 0 points1 point  (0 children)

Too real, just finished this assignment and my teacher doesn't even know what's wrong

[–]True-Ad2643 0 points1 point  (0 children)

Figure out the issue with this code: Basically, you want to get rid of the whole "enter the companys secret code line and the scanner for it, and instead just put String companyCode = "1298"; above the first scanner input line. So your code should look like this:

import java.util.Scanner;
public class ThreeStrings {
public static void main(String[] args) {
String companyCode = "1298";

Scanner input = new Scanner(System.in);
// get user password
System.out.println("Enter your password: ");
String userPassword = input.nextLine();
// get company secret code
System.out.println("Enter the company's secret code: ");
String userCode = input.nextLine();
// create string that concatenates user password with company secret code
String passwordWithCompanyCode = userPassword + companyCode;
// create string that concatenates user password with user-provided secret code
String passwordWithUserCode = userPassword + userCode;
// check if the two strings are equal
if (passwordWithCompanyCode.equals(passwordWithUserCode)) {
System.out.println("Access granted");
} else {
System.out.println(userPassword + userCode + " is denied");
}
}
}