Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 True and False Program
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Egyptian Mafia




PostPosted: 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



exam.t
 Description:
I looked at the tutorial posted in the links but the program tells me stuff is illegal?!!!

Download
 Filename:  exam.t
 Filesize:  721 Bytes
 Downloaded:  184 Time(s)


data.t
 Description:
Correct Answer

Download
 Filename:  data.t
 Filesize:  12 Bytes
 Downloaded:  187 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Mon May 10, 2004 8:58 pm   Post subject: (No subject)

http://www.compsci.ca/v2/viewtopic.php?t=4540

The Search button sometimes is useful for this forum! Really!

Hmm...you may need this too:
http://www.compsci.ca/v2/viewtopic.php?t=5
Egyptian Mafia




PostPosted: Mon May 10, 2004 9:11 pm   Post subject: (No 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
Egyptian Mafia




PostPosted: Mon May 10, 2004 11:32 pm   Post subject: (No 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
Dan




PostPosted: Tue May 11, 2004 3:48 pm   Post subject: (No 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:

code:

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


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.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Egyptian Mafia




PostPosted: Tue May 11, 2004 3:58 pm   Post subject: (No subject)

Hacker Dan, do you have MSN Messenger. add me please

egyptianmafia@hotmail.com So i can tell u what exactly what i want to do.

Thanks a lot Smile
Egyptian Mafia




PostPosted: Tue May 11, 2004 4:12 pm   Post subject: (No subject)

Here is the exact question... it is long...so 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
Delos




PostPosted: Tue May 11, 2004 6:31 pm   Post subject: (No subject)

First, let's clean up some errors:

code:

      get: stremin, "data.t"


should read something like:

code:

      get: stremin, aVarInWhichToStoreTheStuffGottenFromTheStream


obviously, with a shorter name for the second variable.

Then:
code:

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.

code:

      numberofmarks += 1

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

code:

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.
Sponsor
Sponsor
Sponsor
sponsor
Egyptian Mafia




PostPosted: Tue May 11, 2004 8:06 pm   Post subject: (No subject)

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




PostPosted: Tue May 11, 2004 8:42 pm   Post subject: (No 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...



exam.t
 Description:
The proggie with the code from delos...

Download
 Filename:  exam.t
 Filesize:  629 Bytes
 Downloaded:  199 Time(s)

Delos




PostPosted: Tue May 11, 2004 9:10 pm   Post subject: (No subject)

Dude...seriously.

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.

It's:

get : fileStream, varForStorage

I hope you understand such syntaxial expansions.

Now...try again...
Egyptian Mafia




PostPosted: Tue May 11, 2004 10:19 pm   Post subject: (No 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
Egyptian Mafia




PostPosted: Wed May 12, 2004 12:35 pm   Post subject: (No 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!



true+false.t
 Description:

Download
 Filename:  true+false.t
 Filesize:  977 Bytes
 Downloaded:  198 Time(s)

Egyptian Mafia




PostPosted: Wed May 12, 2004 3:02 pm   Post subject: (No subject)

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

Thanks Smile
Delos




PostPosted: Wed May 12, 2004 3:54 pm   Post subject: (No subject)

Errors:

1)
eg.
code:

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".
i.e.

code:

if mark >=80 and mark <100 then


*************

2.

code:

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:
T
F
T
...
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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 21 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: