Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,983 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,370 people online right now. Registration is fast and FREE... Join Now!




grading test from file

 
Reply to this topicStart new topic

grading test from file

sonzai
23 Nov, 2006 - 06:44 PM
Post #1

New D.I.C Head
*

Joined: 31 Oct, 2006
Posts: 31


My Contributions
This is the question on that i'm suppose to do...
but...i'm going to the point where I don't know what I'm doing anymore...
I know that struct is being used...
but I'm not too clear on how to use it with the code...
...and basically...that's it on all i know...
I'm like a beginner in c++
=.= omg...
o, and how do you use fstream for function call...(if you know what i mean...)
and is it even possible to do this without function call..??

I'm still working on the code in misery so it's like only 1% of the entire code done....probably even less....

anyway, here's the Q:

Write a program for grading True/False test. The student ID and answers are stored in a file. The first entry in the file contains answers to the test in the form TFFTFFTTTTFTFTFTFTFT

Every other entry in the file is the student ID, followed by a blank, followed by the student's response. For example, the entry ABC54301 TFTFTFTT TFTFTFFTTFT indicates 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. Each correct answer is awarded two points, each wrong answer get -1 point, and no answer gets 0 points.The output should be: the student ID, followed by the answers, followed by the test score, followed by the test grade. Assume the following grade scaling:
A: 90% - 100%
B: 80% - 89.99%
C: 70% - 79.99%
D: 60% - 69.99%
F: 0% - 59.99%
User is offlineProfile CardPM
+Quote Post

okyup
RE: Grading Test From File
23 Nov, 2006 - 07:08 PM
Post #2

D.I.C Head
Group Icon

Joined: 6 Nov, 2006
Posts: 207


Dream Kudos: 175
My Contributions
Full Edit.

Just did this since i was bored. I used a vector<Test> with struct test and just pushed back a temp struct built from every line of the file. You have to give it a shot though. smile.gif

BTW, do you have to store the test info or just display it? You could do it by just reading each line and comparing it to the key and outputting the ID and score...

This post has been edited by okyup: 23 Nov, 2006 - 07:41 PM
User is offlineProfile CardPM
+Quote Post

sonzai
RE: Grading Test From File
23 Nov, 2006 - 08:12 PM
Post #3

New D.I.C Head
*

Joined: 31 Oct, 2006
Posts: 31


My Contributions
i think i just need to display it...

just another question but how do u get a character from the file from main with function call...??
I'm messed up..
User is offlineProfile CardPM
+Quote Post

Dark_Nexus
RE: Grading Test From File
23 Nov, 2006 - 09:14 PM
Post #4

or something bad...real bad.
Group Icon

Joined: 2 May, 2004
Posts: 1,309



Thanked: 3 times
Dream Kudos: 625
My Contributions
read the forum rules,
do not provide code unless the user requesting help has shown some effort.
User is offlineProfile CardPM
+Quote Post

okyup
RE: Grading Test From File
23 Nov, 2006 - 09:16 PM
Post #5

D.I.C Head
Group Icon

Joined: 6 Nov, 2006
Posts: 207


Dream Kudos: 175
My Contributions
QUOTE(Dark_Nexus @ 23 Nov, 2006 - 10:14 PM) *

read the forum rules,
do not provide code unless the user requesting help has shown some effort.


I saw that coming, but this person doesnt know how to open a file and read it. Doubt they know how to use vectors and structs either.

So how do we help them without posting some guide? sad.gif

I guess thats what tutorials are for.
User is offlineProfile CardPM
+Quote Post

NHWC
RE: Grading Test From File
25 Nov, 2006 - 05:48 PM
Post #6

New D.I.C Head
*

Joined: 25 Nov, 2006
Posts: 1


My Contributions
To add information to the first comments and and maybe answer some other questions:

If the person that is posting this question is working on the same thing as I am we have not done vectors nor have we gotten into the heart of arrays, but we know they exist and they can hold data. We have just started structures.

I have created a program and can get the information to display but I can't seem to compare each element with the answer key elements. After I figure out how to compare them there are 3 outcomes if there == plus 2 point if there != -1 point if the student didn't answer 0 points are added. Anyway, I don't want an answer to the problem I learn much better with trial and error but if anyone can point me to a tutorial or has a hint.

Thanks for your time

User is offlineProfile CardPM
+Quote Post

bluesuus
RE: Grading Test From File
27 Nov, 2006 - 12:11 AM
Post #7

D.I.C Head
Group Icon

Joined: 26 Dec, 2005
Posts: 57


Dream Kudos: 25
My Contributions
i jus remebered wen i encountered this exercise.I was doin c++ for fun and i came across it.Well u knw the forum does not allow release of codes.But ive gat sumtin to get u started in comparing.use substring method in a loop to do the comparison of the key and the users answer.
User is offlineProfile CardPM
+Quote Post

Dark_Nexus
RE: Grading Test From File
29 Nov, 2006 - 02:25 PM
Post #8

or something bad...real bad.
Group Icon

Joined: 2 May, 2004
Posts: 1,309



Thanked: 3 times
Dream Kudos: 625
My Contributions
QUOTE
I saw that coming, but this person doesnt know how to open a file and read it. Doubt they know how to use vectors and structs either.

So how do we help them without posting some guide? sad.gif

I guess thats what tutorials are for.


you can use code in examples and out of context of the entire program. try to avoid writing entire solutions or near complete solutions. if you do post entire programs, only use/modify code that the member requesting help has posted.

when you do reply using code, keep in mind that a user may be asking a question in reference to a school based assignment and providing too much information could be considered cheating.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/8/09 07:11PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month