computer science

import java.io.*;
import java.util.*;
public class Project33
{
public static void main(String[] args) throws FileNotFoundException
{
String QuizAnswers = ” “;
double numCorrect = 0;
String Answers = ” “;
String StudentName = ” “;
int index;
int numAnswers = 0;
double grade = 0.0;
double numWrong = 0.0;
Scanner cscan = new Scanner(System.in);
System.out.println(“Please enter the student file name: “);
String filename = ” “;
filename = cscan.nextLine();
// check for existence of file
File file1 = new File(filename);
if (!file1.exists())
{
System.out.println(“File ” + filename + ” does not exist.”);
}
System.out.println(“Please enter the Quiz Key file name: “);
String filename2 = ” “;
filename2 = cscan.nextLine();
// check for existence of file
File file2 = new File(filename2);
if (!file2.exists())
{
System.out.println(“File” + filename2 + ” does not exist.”);
}
System.out.println(“\n\n”);
System.out.println(“Name” + ” ” + ” Correct” + ” ” + ” Wrong” + ” ” + ” Grade”);
System.out.println(“—-” + ” ” + ” ——-” + ” ” + ” —–” + ” ” + ” —–“);

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Scanner ifile2 = new Scanner(file2); // Open the Quiz Key file
while(ifile2.hasNext())
{
QuizAnswers = ifile2.next();
Scanner ifile1 = new Scanner(file1); // Open the Student Quiz file with answers
while(ifile1.hasNext())//Scan each line in student file and collect data
{
Answers = ifile1.next();
numAnswers = Answers.length();
if(numAnswers == 0) // Checks to see if student file doesn’t have any test answers
{
StudentName = StudentName + ” Input Error! No Answer In Student Record On This Line.”;
numCorrect = 0.0;
numWrong = 0.0;
grade = 0.0;
}
StudentName = ifile1.nextLine(); // Collect student name
if(!(StudentName.length() > 0) || StudentName.charAt(1) == ‘ ‘) // Check for Student Name input error
{
StudentName = StudentName + ” Input Error! No Student Name On This Line.”;
}
int numQuizAns = QuizAnswers.length();

if(numAnswers > numQuizAns || numAnswers < numQuizAns) // Check to see if number of student answers matches number of Quiz answers { StudentName = StudentName + " Input Error! Invalid Number of Answers On This Line."; } else { for(index = 0; index < numAnswers; index++) // Scan each char in student answers and compare to quiz answers { if(Answers.charAt(index) == QuizAnswers.charAt(index)) // Add to numCorrect if both characters are equal { numCorrect++; } Else // also test for lowercase letters in Answer string { if(Answers.charAt(index)=='f' && QuizAnswers.charAt(index)=='F') { numCorrect++; } if(Answers.charAt(index)=='t' && QuizAnswers.charAt(index)=='T') { numCorrect++; } } } } numWrong = numQuizAns - numCorrect; // Calculate the number of wrong answers and output results grade = (numCorrect/numQuizAns) * 100; System.out.println(StudentName + " " + " " + numCorrect + " " + numWrong + " " + grade + "%"); numCorrect = 0; } ifile1.close(); } ifile2.close(); } }

Project 33

 

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Write a system to score a set of true/false tests.  There are 15 true/false questions.  True is represented by T and false by F.  The key to the test is in file quizkey.dat.  The student answers are in file quiz.dat.  Each student’s name (maximum of 20 characters) follows the student’s last answer after 1 space.

 

A sample record in quiz.dat looks like

TTFTFFFTTFTFTTF Jill Student

 

The key looks like

TFTTFFTTFTTFTFF

 

The number of students in the class is not known.

Write a report with a heading and columns for name, correct, missed and numerical percentage nicely spaced.

Write the program so that it will grade true/fa/se tests with different numbers of questions.  The number of questions can be determined by the number of T/F in the quizkey.dat file.  No quizzes are more than 100 questions.

 

The user just wants to install a software application and start it running.

 

Follow Project Guidelines

 

Order your essay today and save 25% with the discount code: STUDYSAVE

Order a unique copy of this paper

600 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
Top Academic Writers Ready to Help
with Your Research Proposal

Order your essay today and save 25% with the discount code GREEN