An example input to your program: 1 T T T T T F T T F F Bobb, Bill 123456789 T T
ID: 3853581 • Letter: A
Question
An example input to your program:
1 T T T T T F T T F F
Bobb, Bill 123456789 T T T T T F T T F F
Lou, Mary 974387643 F T T T T F T T F F
Bobb, Sam 213458679 F T F T f t 6 T F f
Bobb, Joe 315274986 t t t t t f t t f f
ZZZZ
which will produce the output:
Results for quiz 1:
123-45-6789 Bill Bobb 10
974-38-7643 Mary Lou 9
213-45-8679 Sam Bobb 5
315-27-4986 Joe Bobb 10
The average score is 8.5
Error processing:
if the answer is neither a T/t or F/f it is considered incorrect.
if no students are in the class, your program will output:
Quiz 1: Empty class data
I have uploaded the image of the question- its better over there!
Also, this was the code that I developed:
import java.io.*;
import java.text.*;
public class Quiz {
public static void main (String [] args) throws IOException
{
int Quiz;
int counter =0;
int studTotal = 0;
int ClassTotal = 0;
BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));
String[] key = stdin.readLine ().split (" +"); //input 1
String[] stdQuiz = stdin.readLine ().split (" +"); //input 2
System.out.println ("Results for quiz 1: ");
while (stdQuiz [0].compareToIgnoreCase ("ZZZZ") != 0) //if input 2 is ZZZZ program terminates
{
counter ++;
Quiz = 0;
studTotal = 0;
for (int i = 0; i < key.length; i++)
{
if (stdQuiz [3].compareToIgnoreCase (key [i]) ==0)
studTotal ++;
Quiz ++;
}
stdQuiz [0] = stdQuiz [0].substring (0, stdQuiz [0].length () -1);
}
if (counter !=0)
System.out.println (counter);
else
System.out.println ("Quiz 1: Empty class data");
}
}
-----------------------------------------------------------------------------------------
NEED IT IN JAVA.
Introduction to arrays and Strings You are going to write a program to perform automated grading for True False quiz. The first line of input will contain the quiz number followed by the answers to the quiz T or F). The subsequent lines of input will contain the student S name (last, first). the student's ID (nine digits). followed by the student's answers to the quiz. Your program terminates processing student data when the string "ZZZZ" as the only data contained in the input. Your program will output the student's ID. the student's name (first last and the score received for the quiz. An example input to your program: 1 T T T T T FF Bobb, Bill 123456789 T T T T TT FF Lou Mary 974387643 FT TT F F Bobb, Sam 213458679 FT FT f t 6 T F f Bobb, Joe 315274986 t t t t t f t t f f which w produce the output Results for quiz 1 123-45-6789 Bill Bobb 10 974-38-7643 Mary Lou 9 Bobb 5 213-45-8679 Sam 315-27-49 Joe Bobb 10 Th e average score is 8.5 Error processing if the answer is neither a TMt or F/fit is considered incorrect. if no students are in the class. your program will output: Quiz 1: Empty class dataExplanation / Answer
Program:-
import java.io.*;
import java.text.*;
public class Quiz
{
public static void main (String [] args) throws IOException
{
int Quiz=0;
int counter=0;
int studTotal;
int ClassTotal = 0;
BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));
String[] key = stdin.readLine ().split (" +"); //input 1
String[] stdQuiz = stdin.readLine ().split (" +"); //input 2
System.out.println ("Results for quiz :"+key[0]); //YOUR CODE MODIFIED HERE
while (stdQuiz [0].compareToIgnoreCase ("ZZZZ") != 0) //if input 2 is ZZZZ program terminates
{
Quiz++;
counter=1;
studTotal = 0;
for (int i = 1; i < key.length; i++) //YOUR CODE MODIFIED HERE
{
if (stdQuiz [i+2].compareToIgnoreCase (key [i]) ==0) //YOUR CODE MODIFIED HERE
{
studTotal ++;
}
}
System.out.println (stdQuiz[2]+" "+stdQuiz[0]+" "+stdQuiz[1]+" "+studTotal); // CODE ADDED HERE
ClassTotal+=studTotal; // CODE ADDED HERE
stdQuiz = stdin.readLine ().split (" +"); //YOUR CODE MODIFIED HERE
}
float average=ClassTotal/Quiz; // CODE ADDED HERE
System.out.println ("The Average score is: "+average); // CODE ADDED HERE
if (counter !=0)
{
System.out.println ();
}
else
{
System.out.println ("Quiz :"+key[0]+" Empty class data");
}
}
}
Output:-
run:
1 T T T T T F T T F F
BOBB BILL 123456789 T T T T T F T T F F
LOU MARY 974387643 F T T T T F T T F F
BOOB SAM 213458679 F T F T F T 6 T F F
BOOB JOE 315274986 T T T T T F T T F F
ZZZZ
Results for quiz :1
123456789 BOBB BILL 10
974387643 LOU MARY 9
213458679 BOOB SAM 5
315274986 BOOB JOE 10
The Average score is: 8.0
BUILD SUCCESSFUL (total time: 2 seconds)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.