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

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




PostPosted: Thu Mar 24, 2005 10:40 pm   Post subject: need fixing

here is my program ...the problem in here is that when i type in "b" for the menu part it doesnt go to the answers instead it just ends the program..plz help..o and can some1 help me on the last part which is if I type "c" the program should exit , dun no how to do that either:(


var font1, font2 : int
font1 := Font.New ("sans serif:18:bold")
font2 := Font.New ("serif:12")
var choice1 : string

Font.Draw ("Please Choose One of the Following By", 10, 300, font1, black)
Font.Draw ("Typeing a, b or c", 10, 250, font1, black)
Font.Draw ("a.) QUIZ", 10, 200, font2, black)
Font.Draw ("b.) ANSWERS", 10, 180, font2, black)
Font.Draw ("c.) QUIT", 10, 160, font2, black)
get choice1
if choice1 = "a" then
cls
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 "\nWhat is the capital of British Columbia"
for i : 0 .. 2
get guess : *
if guess = "Victoria" then
put "yup"
count += 3 - i
exit
end if
put "\nnope, try again"
end for

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

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

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

put "\nWhat is the capital of NewFoundLand and Labrador"
for i : 0 .. 2
get guess : *
if guess = "St John's" then
put "yup"
count += 3 - i
exit
end if
put "\nnope, try again"
end for

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

put "\nWhat is the capital of Nova Scotia"
for i : 0 .. 2
get guess : *
if guess = "Halifax" then
put "yup"
count += 3 - i
exit
end if
put "\nnope, try again"
end for
put "\nyour score is ", count
if count<10 then
put "You can do better than this Sad"
elsif count<20 and count>11 then
put "Good Job!"
elsif count<21 and count<28 then
put "Excellent work"
elsif count=28 then
put "You got PERFECT. congratualtion!"

elsif choice1 = "b" then

put "Province Capital"
put ""
put "Ontario Toronto"
put "Quebec City Quebec City"
put "Manitoba Winnipeg"
put "Saskatchewan Regina"
put "Alberta Edmonton"
put "British Columbia Victoria"
put "NewFoundLand and Labrador St John's"
put "Nova Scotia Fredericton"
put "New Brunswick Halifax"



end if

end if
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Fri Mar 25, 2005 9:35 am   Post subject: (No subject)

use
code:
[code][/code]
tags please.
And, you need to think logically about what you're doing. Think about the placement of your if statement that checks if choice1 = "b".

And, for the last part, the program does finish when you enter c (well, anything other than a [or b, when it gets fixed]).
jrok311




PostPosted: Sat Apr 02, 2005 6:22 pm   Post subject: try this

your "end if is in the wrong spot and you should add a cls to clear the screen in your answers option. Here is the corrected code:

code:

var font1, font2 : int
font1 := Font.New ("sans serif:18:bold")
font2 := Font.New ("serif:12")
var choice1 : string

Font.Draw ("Please Choose One of the Following By", 10, 300, font1, black)
Font.Draw ("Typeing a, b or c", 10, 250, font1, black)
Font.Draw ("a.) QUIZ", 10, 200, font2, black)
Font.Draw ("b.) ANSWERS", 10, 180, font2, black)
Font.Draw ("c.) QUIT", 10, 160, font2, black)
get choice1
if choice1 = "a" then
cls
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 "\nWhat is the capital of British Columbia"
for i : 0 .. 2
get guess : *
if guess = "Victoria" then
put "yup"
count += 3 - i
exit
end if
put "\nnope, try again"
end for

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

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

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

put "\nWhat is the capital of NewFoundLand and Labrador"
for i : 0 .. 2
get guess : *
if guess = "St John's" then
put "yup"
count += 3 - i
exit
end if
put "\nnope, try again"
end for

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

put "\nWhat is the capital of Nova Scotia"
for i : 0 .. 2
get guess : *
if guess = "Halifax" then
put "yup"
count += 3 - i
exit
end if
put "\nnope, try again"
end for
put "\nyour score is ", count
if count<10 then
put "You can do better than this Sad"
elsif count<20 and count>11 then
put "Good Job!"
elsif count<21 and count<28 then
put "Excellent work"
elsif count=28 then
put "You got PERFECT. congratualtion!"

end if

elsif choice1 = "b" then
cls
put "Province Capital"
put ""
put "Ontario Toronto"
put "Quebec City Quebec City"
put "Manitoba Winnipeg"
put "Saskatchewan Regina"
put "Alberta Edmonton"
put "British Columbia Victoria"
put "NewFoundLand and Labrador St John's"
put "Nova Scotia Fredericton"
put "New Brunswick Halifax"



end if
mike200015




PostPosted: Sat Apr 02, 2005 6:53 pm   Post subject: (No subject)

Just to let you know.. there a few mistakes in your answers:

1. It says:
Quote:
Quebec City Quebec City
but it should say:
Quote:
Quebec Quebec City
take off the 1st "City".

2. Capital of New Brunswick is Fredericton, not Halifax.

3. Capital of Nova Scotial is Halifax, not Fredericton.
jamonathin




PostPosted: Sun Apr 03, 2005 2:31 pm   Post subject: (No subject)

lol, gg! Razz
Drakain Zeil




PostPosted: Sun Apr 03, 2005 3:56 pm   Post subject: (No subject)

Now what you could do, is make one big array (or data file, if you have learned that yet) with all of the questions in it.

Then, you only have /one/ IF statement, and you can randomly pull out questions, or get them in an order.

So let's say you have...

var question:array 1..10 as string
var answer: array 1..10, 1..4 as string
var coranswers:array 1..10 as string

and you put in values for all of those 50 lines of text (10 questions, 4 answers each, and coranswer is the correct input for that question).

Now, you can use the Rand.Int to pick between 1 and 10 (you can trap later to make sure no question comes up twice), then from that number stored as a variable (lets call it "q")

you can
put question(q)
for x:1..4
put answer(q,x)
end for

and then check if the input is equal to coranswer(q).

Less code, just a lot of text.
jamonathin




PostPosted: Sun Apr 03, 2005 7:17 pm   Post subject: (No subject)

Cervantes wrote:
use
code:
[code][/code]
tags please.

^ lil easier to read Wink .
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  [ 7 Posts ]
Jump to:   


Style:  
Search: