teacher needs help grading a tf test student IDs and test an

teacher needs help grading a t/f test. student IDs and test answers are stored in a file. the 1st entry in the file contians the answers to the test in the following form: tfftftftftfttttttfffff every other entry in the file is the students response. for ex: abc54301 tftftftftft ftftft indicates that the students ID is abc54301 and the answer to question 1 is true and the second f and so on. the student didn\'t answer a question. the exam has 20 questions and class has more than 150 students. Each correct answer is awarded 2 points, each wrong is -1. and no answer gets 0. write a program that processes the data. the output should be the students ID, followed by the answers, followed by the test score, followed by the test grade, assume the following grade scale: 100-90%=A, 89.99-80=B, 79.99-70=C, 69.99-60=d, and 59.99-0%=F.

also needs to read from a file named TestScores.txt

Java Programming BOOK by D.s. Malik 5th addition

chapter 9 pg 634

Solution

#include <iostream>

#include <fstream>

#include <string>

#include <stdlib.h>

using namespace std;

int main()

{

    string id;

    char answers [20];

    char studentID [9];

    char response;

    char fileName [25];

    int testScore;

   

    cout << \"\ This program will take the teacher\'s correct test answers\";

    cout << \"\ As well as the 150 students answers, and grade the tests.\ \" << endl;

   

    cout << \"Enter the input file name: \";

    cin >> fileName;

    ifstream inFile;

    inFile.open (fileName);

   

    ofstream outFile;

    outFile.open (\"output.txt\");

   

    cout << \"\ Student IDs     |     Answers | % | Grades\";

    cout << \"\ --------------------------------------------\";

    cout << studentID << answers << endl;

   

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

        inFile >> answers [i];

   

    while ( ( inFile >> id))

    {

        cout << \"\ \" << id << \" \";

        inFile.get(response);

        testScore = 0;

       

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

        {

            inFile.get (response);

           

            cout << \" \" << response;

           

            if (response == \' \')

                testScore += 0;

            else

                if (response == answers [i])

                    testScore += 2;

                else

                    testScore += -1;

        }

       

        cout << \"   \" << testScore << \" \";

       

        double p = testScore * 2.5;

       

        if (p >= 90)

            cout << \'A\';

        else

            if (p >=80)

                cout << \'B\';

            else

                if (p >=70)

                    cout << \'C\';

                else

                    if (p >=60)

                        cout << \'D\';

                    else

                        cout << \'F\';

    }

   

    inFile.close();

    outFile.close();

    return 0;

}

teacher needs help grading a t/f test. student IDs and test answers are stored in a file. the 1st entry in the file contians the answers to the test in the foll
teacher needs help grading a t/f test. student IDs and test answers are stored in a file. the 1st entry in the file contians the answers to the test in the foll
teacher needs help grading a t/f test. student IDs and test answers are stored in a file. the 1st entry in the file contians the answers to the test in the foll

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site