
-----------------------------------
pink00rock
Sat Feb 07, 2004 4:18 pm

(TURING) Urgent, need help on multiple choices..
-----------------------------------
Hey!! Sup people? ..
 
I need help badly.. and i'm so confused with the code i have. 

(its a multiple choice question, and i'll show you the problem with it on the buttom)



var answer:string
var counter:int:=0

        put "How many months are there in a year? " 
        put " "
        put "a) 13        "
        put "b) 11        " 
        put "c) 12        " 
        put " "
for i:1..2
        put "Please enter your answer. (type a, b or c)" 
        put " "
get answer
if answer = "c" or answer = "C" then 
put " ---> Correct! Next Question." 
counter:=counter+1
exit 
else 
put "Sorry, guess again" 
end if 
end for

%this is it!


The problem is, when the code is outputted. And the user can only guess twice, but on the 2nd wrong guess, it sas "Sorry, guess again" --> (the output)

How many months are there in a year? 

a) 13        
b) 11        
c) 12        

Please enter your answer. (type a, b or c)

a
Sorry, guess again
Please enter your answer. (type a, b or c)

b
Sorry, guess again

-------------------

the PROBLEM is --> it says "sorry guess again" twice!
i want it to say something like "Sorry, no more guesses --> next question!" 

Can someone please help me, thanks -

-----------------------------------
santabruzer
Sat Feb 07, 2004 4:22 pm


-----------------------------------
anyways.. ehre is a solution :
var answer : string
var counter : int := 0

put "How many months are there in a year? "
put " "
put "a) 13        "
put "b) 11        "
put "c) 12        "
put " "
for i : 1 .. 2
    put "Please enter your answer. (type a, b or c)"
    put " "
    get answer
    if answer = "c" or answer = "C" then
        put " ---> Correct! Next Question."
        counter := counter + 1
        exit
    elsif i = 1 then
        put "Sorry, guess again"
    elsif i = 2 then
        put "Sorry... Too Bad"
    end if
end for

%this is it!


-----------------------------------
Paul
Sat Feb 07, 2004 4:23 pm


-----------------------------------

var answer : string
var counter, counter2 : int := 0

put "How many months are there in a year? "
put " "
put "a) 13        "
put "b) 11        "
put "c) 12        "
put " "
for i : 1 .. 2
    put "Please enter your answer. (type a, b or c)"
    put " "
    get answer
    if answer = "c" or answer = "C" then
        put " ---> Correct! Next Question."
        counter := counter + 1
        exit
    else
        if counter2 = 0 then
            put "Sorry, guess again"
            counter2 := 1
        elsif counter2 = 1 then
            put "Wrong, next question"
        end if
    end if
end for

%this is it!

darn it, took too long to copy and paste, but your way is better santabruzer :D

-----------------------------------
santabruzer
Sat Feb 07, 2004 4:26 pm


-----------------------------------
25 lines.. versus.. 28.. i think we know who the winner is :P...
ah.. that happens to me often.. too.. at the same time the post...

-----------------------------------
Cervantes
Sat Feb 07, 2004 4:32 pm


-----------------------------------
lol its the same thing its just else / if or elsif  :eh:

-----------------------------------
santabruzer
Sat Feb 07, 2004 4:33 pm


-----------------------------------
and another variable.. really .. really.. it's no different :P

-----------------------------------
TheXploder
Sat Feb 07, 2004 4:39 pm


-----------------------------------
or 23 lines:


var answer : string
var counter : int := 0

put "How many months are there in a year? "
put " "
put "a) 13        "
put "b) 11        "
put "c) 12        "
put " "
for i : 1 .. 2
    put "Please enter your answer. (type a, b or c)"
    put " "
    get answer
    if answer = "c" or answer = "C" then
        put " ---> Correct! Next Question."
        counter := counter + 1
        exit
    elsif answer not= "c" and i 