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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

 

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

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
| +
Transcribed Image Text: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 | +
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

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 $
Transcribed Image Text:<> 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 $
Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education