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

Username:   Password: 
 RegisterRegister   
 DESPERATELY NEED HELP: MY PROGRAM WON'T EXIT >>> RE
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Angel




PostPosted: Thu Jan 08, 2004 12:53 am   Post subject: DESPERATELY NEED HELP: MY PROGRAM WON'T EXIT >>> RE

My program won't exit HELP!

code:
Tony was here and attached the code as a file


Please just modify the last parts of teh program so that it exits where required!!! PLEEEEEEEASE!!!



quiz.t
 Description:

Download
 Filename:  quiz.t
 Filesize:  29.54 KB
 Downloaded:  251 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
DanShadow




PostPosted: Fri Feb 06, 2004 2:13 pm   Post subject: (No subject)

lol....im not gonna read all that code. (and its too long, next time, plz just send a ".t" file.) Here is a much easier way to do yours. (and lessss messy)
code:

var length_of_quiz:int:=10
var questions:array 1..length_of_quiz of string
var choice1,choice2,choice3:array 1..length_of_quiz of string
var answer:array 1..length_of_quiz of string
var input:string
var questions_correct:int:=0
questions(1):="What is the point of writing this?"
choice1(1):="To try to help people"
choice2(1):="Im bored...gimme a break"
choice3(1):="Because I have too....if I dont, theyll beat me"
answer(1):="a"
%Put the rest of the questions/answers/choices here

for i:1..length_of_quiz
put questions(i)
put "a) ",choice1(i)
put "b) ",choice2(i)
put "c) ",choice3(i)
put "Your Choice: "..
get input
if input=answer(i) then
put "Correct!!"
questions_correct+=1
else
put "Wrong!! The correct answer was ",answer(i),"!"
end if
delay(3000)
cls
end for

That should work so much better...and might solve your problem..heh
santabruzer




PostPosted: Fri Feb 06, 2004 4:44 pm   Post subject: (No subject)

ah.. you and your copy and paste trivia.. it's just weird.. i find that people would rather copy and paste rather than create an array program, that will read from a file.. kinda like this one 8) .... of course you need a file called "questions.txt", that will have the following format:

code:
question
choice1
choice2
choice3
choice4
answer

the answer must be a one digit number.. of course you can mod the code to your prefernce Razz ...
here it is:

code:
const maxchoice := 4
const maxquestion := 2
var file := "questions.txt"
var filestream : int
var filecount : int := 1
var null : string
var choose : string (1)

type choices :
    record
        quetext : string
        choices : array 1 .. maxchoice of string
        answer : string (1)
    end record

var question : flexible array 1 .. 0 of choices

open : filestream, file, get

loop
    new question, filecount
    loop
        get : filestream, question (filecount).quetext : *
        for i : 1 .. maxchoice
            get : filestream, question (filecount).choices (i) : *
        end for
        get : filestream, question (filecount).answer
        exit
    end loop
    exit when eof (filestream)
    filecount += 1
end loop

close : filestream

for i : 1 .. filecount
    put question (i).quetext
    for k : 1 .. maxchoice
        put k, ") ", question (i).choices (k)
    end for
    put ""
    getch (choose)
    if choose = question (i).answer then
        put "You are Correct!!"
    else
        put "You are wrong"
    end if
    put "Please Press Any Key to Continue"
    getch (choose)
    cls
end for
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 1  [ 3 Posts ]
Jump to:   


Style:  
Search: