10,088 views
20 votes
20 votes
PLEASE HELP
Three string 3.7.9 codehs

PLEASE HELP Three string 3.7.9 codehs-example-1
User Mmccoo
by
2.8k points

1 Answer

7 votes
7 votes

Answer:

import java.util.Scanner;

public class IdentityVerification {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

// get user password

System.out.println("Enter your password: ");

String userPassword = scanner.nextLine();

// get company secret code

System.out.println("Enter the company's secret code: ");

String companyCode = scanner.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

System.out.println("Enter the secret code: ");

String userProvidedCode = scanner.nextLine();

String passwordWithUserCode = userPassword + userProvidedCode;

// check if the two strings are equal

if (passwordWithCompanyCode.equals(passwordWithUserCode)) {

System.out.println("Access granted");

} else {

System.out.println(userPassword + userProvidedCode + " is denied");

}

}

}