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

Write a Java documented program to perform the role of a quiz maker. The program

ID: 3703636 • Letter: W

Question

Write a Java documented program to perform the role of a quiz maker. The program should work as follows:

1. Prompt the student to enter their user name and password. Read the file "UsersInfo_004.txt", which contains a list of all students’ information to validate the login credentials. Start the quiz only when the credentials are correct. After 3 failed attempts, exit the program. 2

. Randomly pick ten questions from the TestBank.txt file.

3. Display one question at a time. Get the answer then move to the next question.

4. Do not accept answers other than true or false (T or F should be fine too). The answers should not be case sensitive.

5. When the user is done with the quiz, print out a report (On screen and on a file) with the below information in it:

• First name • Last name • Score • Elapsed time • User’s answers and the correct answer.

6. Name the file from step 5 as follows: (userName_COSC_236_Quiz_Date_Time), where: • userName is the actual user name of the student who took the quiz. • Date_Time is the date and time of the start of the test.

7. Prompt for another user name and password or done as a user name to exit.

The program should include all or atleast: arrays, methods, files, loops, etc. I can't do anything beyond those topics/more complex because that is all we have learned in class so far. I can't use "Map" or "HashMap", or "WebElement".

Explanation / Answer

CODE:

public static void main(String []args){

   try

{

               int score=0,el=0;

               Scanner sc=new Scanner(System.in);

               System.out.println("enter username");

               String uname=sc.next();

               System.out.println("enter password");

               String pwd=sc.next();

             

FileInputStream fstream = new FileInputStream("c:/Naveen/userDetails.txt");

BufferedReader br = new BufferedReader(new InputStreamReader(fstream));

String strLine;

int count = 0;

count++;

while((strLine = br.readLine())!= null)

{

WebElement userName = driver.findElement(By.id("username"));

WebElement password = driver.findElement(By.id("password"));

                   for(int i;i<=3;i++)

                   {

                      if(uname==userName && pwd==password)

                   {

                       Map<String,Integer> map = new HashMap<String,Integer>();

                           for(int i = 0; i < 1000; ++i)

                       {

                       String s = choose(new File("g:/temp/TestBank.txt "));

                           if(!map.containsKey(s))

                           map.put(s, 0);

                           map.put(s, map.get(s) + 1);

                           if(s=='T')

                           score=score++

                           el=el+60;

                       }

                       System.out.println("First name "+uname+" Last name"+lname+" Score"+Score+" Elapsed time"+el);

                       break;

                   }

                   else{

                     

                   }

                   }

}

in.close();

br.close();

}

catch (Exception e)

{

System.err.println("Error: " + e.getMessage());

}

public static String choose(File f) throws FileNotFoundException

{

String result = null;

Random rand = new Random();

int n = 0;

for(Scanner sc = new Scanner(f); sc.hasNext(); )

{

++n;

String line = sc.nextLine();

if(rand.nextInt(n) == 0)

result = line;  

}

return result;

}

}

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