The history teacher at your school needs help 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: TFFTFFTTTTFFTFTFTFTT Every other entry in the file is the student ID, followed by a blank, followed by the student’s responses. For example, the entry: 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; and 0%–59.99%, F
The history teacher at your school needs help 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:
TFFTFFTTTTFFTFTFTFTT
Every other entry in the file is the student ID, followed by a blank, followed by the student’s responses. For example, the entry:
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
90%–100%, A; 80%–89.99%, B; 70%–79.99%, C; 60%–69.99%, D; and 0%–59.99%, F
![Instructions
Instructions
The history teacher at your school needs help 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:
TFFTFFTTTTFFTFTFTFTT
Every other entry in the file is the student ID,
followed by a blank, followed by the student's
responses. For example, the entry:
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; and 0%-59.99%, F
delmarlearning.com
Ch8_Ex6Data.txt
main.cpp
1 TTFTFTTTETETEFTTETTF
2 ABC54102 T FIFTETTIETTETTE TF
3 DEF56278 TIETEITIETETEFTTETTE
4 ABC42366 TTFTFTTTFTFTFFTTE
5 ABC42586 TTIIETII TEIFFETF
6
U
| +](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Facb878cd-0818-4d41-b0d5-52815936e254%2Fe7d716d7-88f4-454b-b9c3-2a83dc91d7e9%2Fe07cyyq_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
It is still not having successful output and give me still 0%. I am wondering if you could check it and edit the code. Sorry I don't know what is the exact problem....
![<>
go
?
Tasks
Ch8_Ex6Data.txt
1 #include<iostream>
2 #include<fstream>
3 //#include
4 //#include
5 using namespace std;
6 int main()
7 {
8 ifstream infile("Chap8.txt");
9 if (!infile)
Checks
10 {
11 cout << "unable to open file so exiting from program :";
12 return 0;
Test Case Incomplete
Successful Output
13}
14 char answers [25];
Input
15 string str;
16 getline(infile, str);
17 for (int i = 0; i < str.length(); i++)
18 answers[i] = str[i];
19 while (!infile.eof()) {
Output
20 getline(infile, str);
21 int i;
unable to open file so exiting from pr
22 for (i = 0; i < str.length(); i++) {
I
23 if (str[i]
¹) break;
24 else cout << str[i];
Results
25}
26
ABC54102 T FTFIFTTTFTTETTE TF 27 D DEF56278 TTFTF
Expected Output
27 cout << " ";
= 0;
ABC54102 T FTFIFTTTFTTETTE TF 27 D DEF56278 TTFTF 28 int k
29 double score 0;
30 for (int j = i + 1; j < str.length(); j++, k++) {
31 cout << str[j];
32 if (str[j] = ' ')
33 continue;
34 else if (str[j]
==
answers [k])
35 score = score + 2;
36 else if (str[j] != answers[k])
37 score = score - 1;
Run checks
Submit 0%
0.00
out of
10.00
Program Outputs Correctly
O out of 1 checks passed. Review the
results below for more details.
U
main.cpp
+
> Terminal
X +
sandbox $ rm -f a.out
sandbox $
sandbox $
sandbox $ g++ -Wall -std=c++0
x main.cpp
main.cpp: In function 'int ma
in()':
main.cpp:17:19: warning: comp
arison between signed and uns
igned integer expressions [-W
sign-compare]
0; i < str.leng
=
for (int i
th(); i++)
~~~~~~~~~
~ ~ ~ ~
main.cpp:22:15: warning: comp
arison between signed and uns
igned integer expressions [-W
sign-compare]
0; i < str.length()
=
for (i
; i++) {
~~~~
main.cpp:30:23: warning: comp
arison between signed and uns
igned integer expressions [-W
sign-compare]
or (int j = i + 1; j < str.1
ength(); j++, k++) {
~~^~~~~~~
~~~~~~~
sandbox $ ./a.out
unable to open fil
sandbox $](https://content.bartleby.com/qna-images/question/acb878cd-0818-4d41-b0d5-52815936e254/17c09a63-0dc4-4f46-9470-b1aad302e963/mkx062l_thumbnail.png)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)