subject

C++
the history teacher at your school needs in grading a true/false test. the students' ids and test answers are stored in a file. the first entry in the file contains answers to the test in the form:
tffttftftftt
every other entry in the file is the student id, followed by a blank, followed by the student's responses. for example, the
abc54301 tftftftt tftftffttft
indicates that the student id is abc54301 and the answer to question 1 is true, the answer to question 2 is false, and so on. this student did not answer question 9. the exam has 20 questions, and the class has more than 150 students. each correct answer is awarded two points, each wrong answer gets one point deducted, and no answer gets zero points. write a program that processes the test data. the output should be the student's id, followed by the answers, followed by the test score, followed by the test grade.
assume the following grade scale: 90%-100%, a; 80%-89.99%, b; 70%-79.99%, c; 60%-69.99%, d; 0%-59.99%, f.
the input is
tfftttftftffttftttff
lau76359 tftftftftftftftftftf
puc98563 tfftttftftffttffftff
ram69522 tfftttft ffttftttff
gps22106 tfftttftftf
ugp67851
mud02001 t f t f t f t f t f
ibm99887 fttf fttfftffftt
cam78999 ftftft tftftf ftftft
my code is this:
#include
#include
#include
#include
using namespace std;
int main()
{
ifstream infile("chap8.txt");
if (! infile)
{
cout < < "unable to open file so exiting from program : ";
return 0;
}
char answers[25];
string str;
getline(infile, str);
for (int i = 0; i < str. length(); i++)
answers[i] = str[i];
while (! infile. {
getline(infile, str);
int i;
for (i = 0; i < str. length(); i++) {
if (str[i] == ' ') break;
else cout < < str[i];
}
cout < < " ";
int k = 0;
double score = 0;
for (int j = i + 1; j < str. length(); j++, k++) {
cout < < str[j];
if (str[j] == ' ')
continue;
else if (str[j] == answers[k])
score = score + 2;
else if (str[j] ! = answers[k])
score = score - 1;
}
cout < < " ";
double avg = 100.0*score / 40.0;
cout < < avg < < " ";
//90%-100%, a; 80%-89.99%, b; 70%-79.99%, c; 60%-69.99%, d; and 0%-59.99%, f.
if (avg > = 90 & & avg < = 100)
cout < < "a" < < endl;
else if (avg > = 80 & & avg < = 89.99)
cout < < "b" < < endl;
else if (avg > = 70 & & avg < = 79.99)
cout < < "c" < < endl;
else if (avg > = 60 & & avg < = 69.99)
cout < < "d" < < endl;
else if (avg > = -15 & & avg < = 59.99)
cout < < "f" < < endl;
}
return 0;
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 08:30
Intellectual property rights are exclusive rights that protect both the created and the creation. ipr offers exclusively what benefits to the person or people covered by it
Answers: 3
question
Computers and Technology, 24.06.2019 11:00
Need fast im timed in a paragraph of 125 words, explain at least three ways that engineers explore possible solutions in their projects.
Answers: 2
question
Computers and Technology, 24.06.2019 12:50
Write a new lc-3 trap subroutine (i.e. a subroutine that will be invoked via the trap instruction) that will receive a numeric digit entered at the keyboard (i.e. an ascii character), echo it to the screen, and return in r0 the corresponding numeric value: so if the user types the digit '7', the character '7' will appear on the screen, but the value returned in r0 will be b0000 0000 0000 0111 (#7) you may not use any trap calls in your code - you must implement the "polling" code that interrogates the keyboard status and data registers. ; getnum_tsr ; a subroutine for obtaining a numeric value ; given ascii numeric digit input to keyboard. ; the numeric digit is echoed to the console (e.g. '7' = b0000 0000 0011 0111), ; but the value returned in r0 is the actual numeric value ; corresponding to the digit (e.g. b0000 0000 0000 0111 =
Answers: 3
question
Computers and Technology, 24.06.2019 14:00
When creating a field in a table, you must set the to determine what type of data the field can store. field property data type field type data property
Answers: 1
You know the right answer?
C++
the history teacher at your school needs in grading a true/false test. the students' ids...
Questions
question
Mathematics, 20.11.2020 17:30
question
Physics, 20.11.2020 17:30
question
Mathematics, 20.11.2020 17:30
question
English, 20.11.2020 17:30
question
Mathematics, 20.11.2020 17:30
question
Mathematics, 20.11.2020 17:30
question
Mathematics, 20.11.2020 17:30
Questions on the website: 13722360