Question: Hello experts, I have a dead code warning for line 266. I can't figure out a fix. This is what it's supposed to do: However,
Hello experts, I have a "dead code" warning for line 266. I can't figure out a fix.
This is what it's supposed to do:

However, when running the code with the "dead code warning" I get this. It doesn't show the questions gathered from TestBank.txt:

Here is the code that needs fixing:
import java.util.*; import java.io.*; import java.text.*;
public class QuizMaker { final int QUESTION_COUNT = 125; class User { String firstname; String lastname; String username; String password; String email; String role; public String getFirstname() { return firstname; } public String getRole() { return role; } public void setRole(String role) { this.role = role; } public void setFirstname(String firstname) { this.firstname = firstname; } public String getLastname() { return lastname; } public void setLastname(String lastname) { this.lastname = lastname; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } }; // Reads UsersInfo_004.txt static List usersmethod() throws IOException { List userList = new ArrayList(); BufferedReader br1 = new BufferedReader(new FileReader("UsersInfo_004.txt")); String line = ""; while ((line = br1.readLine()) != null) { String[] u = line.split("\t"); User user = new QuizMaker().new User(); user.setUsername(u[0]); user.setPassword(u[1]); user.setFirstname(u[2]); user.setLastname(u[3]); user.setEmail(u[4]); user.setRole(u[5]); userList.add(user); } br1.close(); return userList; } // Reads TestBank.txt static List questionmethod() throws IOException { List questionList = new ArrayList(); BufferedReader br1 = new BufferedReader(new FileReader("TestBank.txt")); String line = ""; while ((line = br1.readLine()) != null) { questionList.add(line); } br1.close(); return questionList; } // Reads Answers.txt static List answersmethod() throws IOException { List answerList = new ArrayList(); BufferedReader br1 = new BufferedReader(new FileReader("Answers.txt")); String line = ""; while ((line = br1.readLine()) != null) { answerList.add(line); } br1.close(); return answerList; } static String exitMethod() { Scanner scan = new Scanner(System.in); System.out.print("Do you want to take the quiz with another user name?" + " If so, enter YES, otherwise enter done. "); String opt = scan.nextLine(); return opt; } public static void main(String[] args) throws IOException { List userList = new ArrayList(); List questionList = new ArrayList(); List answerList = new ArrayList(); User userAcc = null; int score = 0; int[] ranQns = new int[10]; userList = usersmethod(); questionList = questionmethod(); answerList = answersmethod(); Scanner scan = new Scanner(System.in); String filename =""; int attempt = 1; boolean loginSuccess = false; do { System.out.print("Enter Username: "); String uname = scan.nextLine(); for (User user : userList) { if (user.getUsername().equals(uname)) { do { System.out.print("Enter password: "); String password = scan.nextLine(); if (user.getPassword().equals(password)) { loginSuccess = true; System.out.println("Login accepted, welcome " + user.getFirstname() + "."); userAcc = user; break; } else { System.out.println("Invalid password: "); attempt++; } } while (attempt 3) { System.out.println("3 Failed attempt. Closing application"); System.exit(0); } if (loginSuccess && userAcc.getRole().equals("Student")) { /* Random rand = new Random(); for(int i=0;i

> run QuizMaker Enter Username Enter password: Welcome Katy Login Accepted. Get Ready to take Quiz. Type Either True/False or T/F ?:You need to initalize a variable before you can use it. Answer Array indexes always starts at 0 Answer: T Arrays may not be ofany type. Answer F Once created, an array size can be modified
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
