Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Help, here is my program below. I am having acouple errors with my program

ID: 3577708 • Letter: J

Question

Java Help, here is my program below. I am having acouple errors with my program that I cant seem to figure out what the problem is.

1. The program prompts the user for a user name and a password, getting those values from the user at run time.

2. The text for the prompts comes from a Resource Bundle

3. Once the user has supplied both values, verify them against hard coded values in the program

4. If the user name and password match, show a success message from the Resource Bundle

5. If the user name and password do not match, show an error message from the Resource Bundle

6. Store the results to a file, the name of which is stored in the Resource Bundle. Make sure each record is labeled with labels from the Resource Bundle.

7. Create a second Resource Bundle for a language of your choosing. If you only know one language, you can use Google Translate or another person to help with translation. If you don't have those resources available, just add "(in )" to the end of the values.

8. Repeat steps 1 through 6 using the second Resource Bundle (set the Locale to do this).

import java.io.File;

import java.io.FileNotFoundException;

import java.io.PrintWriter;

import java.util.Scanner;

public class ResourceBundle { public static void main(String[] args) {

Scanner scan = new Scanner(new File("the\dirmyFile.extension"));

Scanner input = new Scanner(System.in);

String username;

String password;

String username = scan.nextLine();

String password = scan.nextLine();

String inpUsername = keyboard.nextLine();

String inpPassword = keyboard.nextLine();

System.out.println("Log in: ");

System.out.println("username: "); username = input.next();

System.out.println("password: "); password = input.next();

if (inpUsername.equals(username) && inpPassword.equals(password)){

System.out.print("success message: ");

System.out.print("You are logged in: "); }

else {

System.out.print("Error message: ");

System.out.print("Invalid username or password");

}

}

}

Explanation / Answer

package dec13;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class ResourceBundle {
   public static void main(String[] args) throws FileNotFoundException {
       boolean flag = false;
       Scanner scan = new Scanner(new File("input1.txt"));
       Scanner input = new Scanner(System.in);
      
       System.out.println("Log in: ");
       System.out.println("username: ");
       String username = input.next();
       System.out.println("password: ");
       String password = input.next();
      
       String inpUsername = "";
       String inpPassword = "";
      
       while (scan.hasNextLine()) {
           String s = scan.nextLine();
           String str[] = s.trim().split("\|");
           inpUsername = str[0];
           inpPassword = str[1];
          
           if (inpUsername.equals(username) && inpPassword.equals(password)) {
               flag = true;
               break;
           }
       }
      
       if(flag){
           System.out.println("success message: ");
           System.out.println("You are logged in: ");
       } else {
           System.out.println("Error message: ");
           System.out.println("Invalid username or password");
       }
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote