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

Username:   Password: 
 RegisterRegister   
 need help with assigment
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
recyclebin123




PostPosted: Wed Mar 23, 2005 11:28 pm   Post subject: need help with assigment

umm for my comp sci class i need to make a quiz thing that will ask the user for the capital of a province in canada and he will get 3 trys before moving on and if he or she gets it right the first time he gets 3 points and second guess he gets 2 points and 3rd guess he gets 1 point. Unfortunately i do not know how to do this. This is all i got so far.........

var tor, quecity, vict, edm, reg, winni, stj, fred, hali : string
var count : int := 0
put "Please answer with capital letters for first letter"
put "You get THREE trys for each question"
put ""
put ""
put "What is the capital of Ontario"
loop
count := count + 1
get tor
if tor = "Toronto" then
put "You are correct"
else
put "You are wrong. Please Try again"
end if
exit when count = 3 or tor = "Toronto"
end loop

put ""
put ""
put "What is the captial of Quebec"
loop
count := count+1
get quecity
if quecity = "Quebec City" then
put "You are correct"
else
put "Nope sorry. Youre Wrong"
end if
exit when count = 6 or quecity = "Quebec City"
end loop


This sort of works but i dun no how to do the points part and how to end it if the user were to get it rite on the second try or first.
Sponsor
Sponsor
Sponsor
sponsor
Naveg




PostPosted: Wed Mar 23, 2005 11:34 pm   Post subject: (No subject)

code:
var points:int
if count=1 then
points:=3      %3 points if on first try
elsif count=2 then
points:=2
elsif count=3 then
points:=1
end if
zylum




PostPosted: Thu Mar 24, 2005 12:50 am   Post subject: (No subject)

like this?

code:
var guess : string
var count : int := 0
put "Please answer with capital letters for first letter"
put "You get THREE trys for each question\n\n"

put "What is the capital of Ontario?"
for i : 0 .. 2
    get guess : *
    if guess = "Toronto" then
        put "yup!"
        count += 3 - i
        exit
    end if
    put "\nnope, try again"
end for

put "\nWhat is the capital of Quebec?"
for i : 0 .. 2
    get guess : *
    if guess = "Quebec City" then
        put "yup!"
        count += 3 - i
        exit
    end if
    put "\nnope, try again"
end for

put "\nyour score is ", count
Mr. T




PostPosted: Thu Mar 24, 2005 12:50 am   Post subject: (No subject)

code:

get quecity
if quecity = "Quebec City" then


Since Quebec City is a string with two words, you need to make your get statement compatible.

code:

get quecity :*
if quecity = "Quebec City" then


Good Luck.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: