Computer Science Canada

True and False Program

Author:  Egyptian Mafia [ Mon May 10, 2004 8:23 pm ]
Post subject:  True and False Program

Ok, I need to make a true and false program. The program has a student id # and an answer string of each student. for example

ID # 0080 he answered FTTFTFTTFT
ID # 0340 he answered FTFTFTTTFF

So I need to make a data file which stores the correct answer which is FTFFTFFTFT which I already done. I have started the program but i am stuck on which I should do next. I also need to give grades according to the percentage of the correct answer so A is Best 1 pr Best -1 and B if Best -2 and C for Best-3 and Give F for failures.

I am going to attach both the program i made which i started and the data file that includes the correct answer. I need please someone who is generous enough to put me on the right track and just add a few lines or show me the codes to what i should put next. Once again, i am an extreme n00b.

Thanks Smile

EDIT: I Changed the exam.t with the new code i got from the tutorial and still it does not work. Please check it out.

Thanks Smile

Author:  Delos [ Mon May 10, 2004 8:58 pm ]
Post subject:

The Search button sometimes is useful for this forum! Really! may need this too:

Author:  Egyptian Mafia [ Mon May 10, 2004 9:11 pm ]
Post subject: 

Please check re-attached exam.t with the new code entered from the tutorial, i copied it and it still not working.

Thanks Smile

Author:  Egyptian Mafia [ Mon May 10, 2004 11:32 pm ]
Post subject: 

Come on guys, I am not asking for you guys to make me the proggie. I just need few codes to get me started from where i stopped. Please...

Thanks Smile

Author:  Dan [ Tue May 11, 2004 3:48 pm ]
Post subject: 

Well u may whont to read the tutorial a litte closer.

U use "data.t" as if was a varibale but it is not, it is a string. Also you are then trying to add a string value to a int witch dose not work.

Also i dont understand how you are trying to conver a line of Fs and Ts to a number. All u do is add the string to total and then have a var caled marks withc u check but never set.

i could help but i do not fully understand what you are trying to do. Where are the sutdtends aswers coming from (file or user input and what file if it is a file) and where is the output going(file or screen and what file and in what form)? is the answer the only thing it the data file? and will it allways be the only thing in that file? if so then you do not need to use a loop to get the input and just need one get stament like this:


var stremin :int
open: stremin, "data.t", get
var line : string
get: stremin, line

and the line of F and T will be in the var line. then u just need to uses substrings in a for loop to check the anwers agested the right one.

Author:  Egyptian Mafia [ Tue May 11, 2004 3:58 pm ]
Post subject: 

Hacker Dan, do you have MSN Messenger. add me please So i can tell u what exactly what i want to do.

Thanks a lot Smile

Author:  Egyptian Mafia [ Tue May 11, 2004 4:12 pm ]
Post subject: 

Here is the exact question... it is bare with me...

Write a program that first reads in the answer strings representing the 10 correct answers ( use FTFFTFFTFT as data) Next, for each student, read the students's data and compute and store the number of correct answers for each student in one array. Determine the best score, Best. Then print a three column table displaying the ID number, score and grade for each student. The grade should be determined as follows : If the score is equal to Best or Best-1, give A; if it is Best-2 or Best-3, give C. Otherwise, give an F. then , Modify the test scoring program developed for programming the first project to allow for multiple-choice questions having answers A through E. Compute the average number of correct answers, the range of scores ( that is, largest number correct to smallest number correct), and the average of the grades assigned ( use the grade point equivalencies) A=4.0, C=2.0 and F=0.0

Boy, am i screwed. This program maybe so easy for you guys but to me it is HELL! Crying or Very sad I seriousily dont know what i am doing. All i know is what i made in the proggie i attached. I am SOL! Please help me. Smile

Thanks a lot. Smile

Author:  Delos [ Tue May 11, 2004 6:31 pm ]
Post subject: 

First, let's clean up some errors:


      get: stremin, "data.t"

should read something like:


      get: stremin, aVarInWhichToStoreTheStuffGottenFromTheStream

obviously, with a shorter name for the second variable.


totalInStringFormat += aVarInWhichToStoreTheStuffGottenFromTheStream

Notice that 'totalInStringFormat' is indeed in string format. It would be impossible to assign the value of 'T' or 'A' or even 'F' to an int variable.


      numberofmarks += 1

The prog WILL crash here unless you instantiate (that is to say, initialize) the variable before it gets here.


var numberofmarks : int := 0

That's for now.
Press F2.

Fix that, get some more code done, and then we'll see what's next.

Author:  Egyptian Mafia [ Tue May 11, 2004 8:06 pm ]
Post subject: 

Thanks man, I will work on it now and I will post the program with the new code. Smile

Author:  Egyptian Mafia [ Tue May 11, 2004 8:42 pm ]
Post subject: 

Ok, i put in the codes and yea...they dont work...I dont know if i put them in right or wrong.... Question

Thanks Smile The progggie is attached here...

Author:  Delos [ Tue May 11, 2004 9:10 pm ]
Post subject: 


That whole excessively lenghty named variable was a touch of sarcasm. You need to declare variables before they can be used you know...

And you still havn't quite got the concept of 'get:'ing.


get : fileStream, varForStorage

I hope you understand such syntaxial expansions.

Now...try again...

Author:  Egyptian Mafia [ Tue May 11, 2004 10:19 pm ]
Post subject: 

Delos, could you please post the code in the program and attach it. I seriousily did everything you told me but it does not work.

Thanks man Smile

Author:  Egyptian Mafia [ Wed May 12, 2004 12:35 pm ]
Post subject: 

Guys, how about this...I worked really hard on this version here. I just need to finish up the proggie...Could someone please help me finish it

Thanks Smile

proggie attached!

Author:  Egyptian Mafia [ Wed May 12, 2004 3:02 pm ]
Post subject: 

Guys, I really need your help...This is due very soon.

Thanks Smile

Author:  Delos [ Wed May 12, 2004 3:54 pm ]
Post subject: 



if mark >=80 and <100 then

That will not work. Sorry to say this, but do you ever actually run your programmes before posting them? Because if you're going to post something, at least try and fix as many errors as you can - especially ones like these...(if you genuinely don't understand the error, then don't worry)...anyway, on with the business.

You can't code the way you talk. Got that? So, you can't say "if the mark is greater than or equal to 80 and less than 100 then". Computers are stupid. Keep that in mind. Instead, say "if the mark is greater than or equal to 80 and the mark is less than 100 then".


if mark >=80 and mark <100 then




for x : 1 .. 10
    get : stream, ans1 (x)
end for

I take it you have no idea what the 'get :' command does. Or at least a very small one.
'get :' reads an entire line from a file. So, for looping this 10 times means that it will try to get 10 lines! But as you know, there is only 1 line in your data.t file.
So, do one of two things:
- in data.t, make sure that there are 10 lines. Instead of "TFTTTFFTFF", have it as:
that way you'll have 10 lines, and each line will go into the right element in your array.
- or you could only have 1 line, read that line from the file (without a for loop), and then with a for loop divide it up into 10 seperate letters, which you'd then store into your array.


Fix and repost.

Author:  Egyptian Mafia [ Wed May 12, 2004 4:17 pm ]
Post subject: is the data.t it has TFTFTF as the correct answer...and then each student id and his own TFTF answer and i must match student id answer with the main TFTFTF answer.. like what the question asks.

Thanks a lot man. Smile Appreciate your help.

Author:  Egyptian Mafia [ Wed May 12, 2004 6:07 pm ]
Post subject: 

Come on guys, I really need help...:0

Thanks Smile

Author:  Egyptian Mafia [ Wed May 12, 2004 7:25 pm ]
Post subject: 

Ok, I got it to work...I need help on the last part. Come on guys, just the last part. Here is the last part.

The grade should be determined as follows : if the score is equal to Best or Best-1 give A if it is Best-2 give B and Best-3 give C otherwise F. Modify he test scoring program to allow for multiple choice questions having A through E. Compute the average number of correct answers, the range of scores Largest number to smallest number correct and the average grades assigned. A=4.0 C=2.0 and F=0.0

Thanks a lot guys Smile Proggies are attached once again.

Author:  Delos [ Wed May 12, 2004 8:18 pm ]
Post subject: 

You will need to do this:

- store all scores in an array
- sort the array in descending order (Bubble Sort will be easiest)
- then, match the ID #s with their scores with the sorted score list, and from there assign a ranking.

- to convert to ABCDE, just add extra conditions instead of just TF...but then looking at the way you've set up your checking, it won't be as difficult...good job there.

Author:  Egyptian Mafia [ Wed May 12, 2004 9:35 pm ]
Post subject: 

Delos, are talking to a dumb person when it comes to turing. Could you please should be codes like before.

Thanks. Smile

Author:  Delos [ Thu May 13, 2004 4:43 pm ]
Post subject: 

Let's see...

"store all scores in an array"
- that cannot be at all difficult...use ':='...

"sort the array..."
- the Bubble Sort is very may already have learnt it...
This will explain it well.

"then, match the ID..."
- just use if's...
if ID1's score = topScore then
ID1's grade := 'A'