Java Lab 12
Java Lab 12
Create a new Java file (empty Java file), save it to your H: drive, call it lab12
Insert the following code to set up your program:
Be sure to copy the test text files to the location where you saved your Java file
import java.util.Scanner;
import java.io.*;
studentGrades.close();
100pt:
You are a lazy teacher with a lot of tests to grade. Luckily, you know how to program to make
your life somewhat easier.
The test had 10 multiple choice questions, with answers A, B, C or D. The key to this part of the
test is listed in the String array testAnswers.
All of the student answers have been stored in a text file, along with their name. An example
line of text from the file looks like this:
S631092,A,C,D,B,C,D,B,A,D,A
Using the testAnswers array as a key, grade every student in the test and give them a
percentage grade. You must use a loop to do the comparisons. Your example output for one
student should look as follows:
S631092: 100%
Notes:
String split():
String comparisons:
if(splitLine[2].equals(testAnswers[0]){
// Do Something
Use the following while loop to read in the file, line by line:
while(fileInput.hasNextLine()){