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

plz question 6 Programming Exercises I 603 n that prompts the user to input a st

ID: 3712065 • Letter: P

Question

plz question 6

Programming Exercises I 603 n that prompts the user to input a string and outputs the e letters. (Use a character array to store the string) school needs help in grading a True/False test. ents IDs and test answers are stored in a file. The first entry in the history teacher at your ne ile contains answers to the test in the form: FFTETETETT in the file is the student ID, followed by a blank, followed h the student's responses. For example, the entry: by ETFTFFTTET ABC54301 TETFTFTT T that the student I D is ABC54301 and the answer to question 1 is True, on 2 is False, and so on. This student did not answer question 9 more than 150 students. Each correct is awarded two points, each wrong answer gets one point deducted, and no zero points. Write a program that processes the test data. The output estudent's ID, followed by the answers, followed by the test score, on wed by the test grade. Assume the following grade scale: 90%-100%, A; 80%- The exam has 20 questions, and the class has answer gets 89.998. B: 70%-79.99%, ?; 60%-69.99%, Dand 08-59.998, F be th n that allows the user to enter the last names of five candidates in 7: Write a progra ocal election and the number of votes received by each candidate. The 8 a l program received, and the percentage of the total votes received by the candidate. Your program should then output each candidate's name, the number of votes should also output the winner of the election. A sample output is: Votes Received % of Total Votes Candidate Johnson Miller Duffy Robinson Ashtony Total 5000 4000 6000 2500 1800 19300 25.91 20.73 31.09 12.95 9.33 The Winner of the Election is Duffy Consider the following function main: int main () int instock[101141: int alpha[201; int beta[201: int gamma[ 4] (11, 13, 15, 17)2 int deltat10] (3, 5, 2, 6, 10, 9, 7, 11, 1, 8)

Explanation / Answer

Solution:

Note: C++ is used to implement.

code:

#include <iostream>
#include <fstream>
#include <string>
#include<iomanip>
using namespace std;
char letter(int);
int main()
{char key[21],answer[21],id[9];
int score,i;
char space;
ifstream in;
in.open("input.txt");           //open file
if(in.fail())             //is it ok?
    { cout<<"file did not open please check it ";
     system("pause");
     return 1;
        }
ofstream outFile;
outFile.open("Output.txt");
in.get(key, 21);
in>>id;

while(in)
    {in.get(space);
    for(i=0;i<20;i++)
       answer[i]=' ';
     answer[20]='';
    in.get(answer,21);
       
   
   score = 0;       
     for(i=0;i<20; i++)
       {if(answer[i]==' ')
           score+=0;
       else if(answer[i]==key[i])
          score+=2;
        else
          score--;
          }
       outFile<<id<<" "<<setw(21)<<left<<answer<<" "<<score<<" "<<letter((int)((double)score/40.*10.))<<endl;
      in>>id;
      }
in.close();
outFile.close();

    return 0;
}

char letter(int score)
{switch(score)
    {case 10:
     case 9: return 'A';
     case 8: return 'B';
     case 7: return 'C';
     case 6: return 'D';
     default: return 'F';
    }
}

I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)