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

Username:   Password: 
 RegisterRegister   
 two questions
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
4sak3nX




PostPosted: Sun Mar 28, 2010 11:44 am   Post subject: two questions

HEy all i got two questions for you all involving how to do something Very Happy

first off i have a program that is a 5 question quiz. I want to add a couple of sound clips depending on how the user did. this leads me to the second point. How do i track how many questions the user got right and how many they didnt?

here is the program...


Turing:

var a1 : string
var a2 : string
var a3 : string
var a4 : int
var a5 : string
var a6 : string

setscreen ("graphics")
colourback (black)

loop
    put "Welcome to THE QUIZ!"
    colour (yellow)
    put " Question 1. Who is the greatest person ever? " ..
    get a1
    if a1 = "Barney" then
        colour (green)
        put " "
        put "That is correct! Barney is the greatest person ever!"
    else
        colour (red)
        put " "
        put "Im sorry, Barney is the correct answer not ", a1
    end if

    colour (yellow)
    put " "
    put " Question 2. What is the name of the best band ever? " ..
    get a2
    if a2 = "GunsNRoses" then
        colour (green)
        put " "
        put "That is correct! Guns N Roses is the greatest band ever!"
    else
        colour (red)
        put " "
        put "Im Sorry, GunsNRoses is the correct answer, not ", a2
    end if

    colour (yellow)
    put " "
    put " Question 3. What Operating system do you use? " ..
    get a3
    if a3 = "vista" then
        colour (green)
        put " "
        put "Thats right! You use Vista! Join the club!"
    else
        colour (red)
        put " "
        put "No you use vista silly! Not ", a3
    end if

    colour (yellow)
    put " "
    put " Question 4. How old are you? You cant get this wrong! " ..
    get a4
    if a4 <= 16 then
        colour (green)
        put " "
        put "You are in the 15 and under age group!"
    else
        colour (green)
        put "You are in the 17 and older age group!"
    end if

    colour (yellow)
    put " "
    put " Question 5. The greatest man alive made this quiz. Who is he? " ..
    get a5
    if a5 = "Curtis" then
        colour (green)
        put " "
        put "Thats correct! Curtis Gaunt is the greatest man alive!"
    else
        colour (red)
        put " "
        put "No, no, no! Curtis is the greatest man alive, not ", a5
    end if

    colour (blue)
    put "Thanks for playing! Would you like to play again? " ..
    get a6
    exit when a6 = "no"
end loop




all help appreciated!
Sponsor
Sponsor
Sponsor
sponsor
livingheaven




PostPosted: Sun Mar 28, 2010 11:49 am   Post subject: Re: two questions

have 2 totals

var t1 ,t2,tt : int := 0

then when the user gets something wrong

t2 := t2 +1

and when the user gets something right

t1 := t1 + 1

to see how the user did you can do

tt := t1+t2

if t1 >= 50 then
put "you have passed the quiz."
Music.PlayFileReturn("the music you want to play")

elsif t1 < 50 then
put "you have failled the quiz."
Music.PlayFileReturn("the music you want to play")


hope this helps Very Happy
GL
livingheaven




PostPosted: Sun Mar 28, 2010 11:51 am   Post subject: Re: two questions

sry ... forgot to end if
Very Happy
4sak3nX




PostPosted: Sun Mar 28, 2010 11:53 am   Post subject: RE:two questions

ok ill try this out and get back to you.
4sak3nX




PostPosted: Mon Mar 29, 2010 9:14 am   Post subject: RE:two questions

ok the counting works fine but the sound wont play.

i put the sound name into the brackets under quotations but it wont play.
USEC_OFFICER




PostPosted: Mon Mar 29, 2010 11:49 am   Post subject: RE:two questions

Are they in the same location?/The folder they are in is in the same location. That's very important. Did you try it with single/double quotations?
4sak3nX




PostPosted: Tue Mar 30, 2010 9:09 am   Post subject: RE:two questions

Turing:

var a1 : string
var a2 : string
var a3 : string
var a4 : int
var a5 : string
var a6 : string
var t1, t2, tt : int := 0

setscreen ("graphics")
colourback (black)

loop
    colour (yellow)
    put "Welcome to THE QUIZ!"
    colour (yellow)
    put " Question 1. Who is the greatest person ever? " ..
    get a1
    if a1 = "Barney" then
        colour (green)
        put " "
        put "That is correct! Barney is the greatest person ever!"
        t1 := t1 + 1
    else
        colour (red)
        put " "
        put "Im sorry, Barney is the correct answer not ", a1
        t2 := t2 + 1
    end if

    colour (yellow)
    put " "
    put " Question 2. What is the name of the best band ever? " ..
    get a2
    if a2 = "GunsNRoses" then
        colour (green)
        put " "
        put "That is correct! Guns N Roses is the greatest band ever!"
        t1 := t1 + 1
    else
        colour (red)
        put " "
        put "Im Sorry, GunsNRoses is the correct answer, not ", a2
        t2 := t2 + 1
    end if

    colour (yellow)
    put " "
    put " Question 3. What Operating system do you use? " ..
    get a3
    if a3 = "vista" then
        colour (green)
        put " "
        put "Thats right! You use Vista! Join the club!"
        t1 := t1 + 1
    else
        colour (red)
        put " "
        put "No you use vista silly! Not ", a3
        t2 := t2 + 1
    end if

    colour (yellow)
    put " "
    put " Question 4. How old are you? You cant get this wrong! " ..
    get a4
    if a4 <= 16 then
        colour (green)
        put " "
        put "You are in the 15 and under age group!"
        t1 := t1 + 1
    else
        colour (green)
        put "You are in the 17 and older age group!"
        t1 := t1 + 1
    end if

    colour (yellow)
    put " "
    put " Question 5. The greatest man alive made this quiz. Who is he? " ..
    get a5
    if a5 = "Curtis" then
        colour (green)
        put " "
        put "Thats correct! Curtis Gaunt is the greatest man alive!"
        t1 := t1 + 1
    else
        colour (red)
        put " "
        put "No, no, no! Curtis is the greatest man alive, not ", a5
        t2 := t2 + 1
    end if

    tt := t1 + t2

    if t1 <= 50 then
        colour (yellow)
        put "You have passed the quiz with a total of ", t1
        Music.PlayFileReturn ("announcer_success")
    elsif t1 > 50 then
        colour (yellow)
        put "You have failed the quiz with a score of ", t1
        Music.PlayFileReturn ("announcer_failure")
    end if

    colour (blue)
    put "Thanks for playing! Would you like to play again? " ..
    get a6
    exit when a6 = "no"
end loop




thats what i have and both sounds are on my desktop
chrisbrown




PostPosted: Tue Mar 30, 2010 10:02 am   Post subject: RE:two questions

Windows hides extensions by default. You need to add .mp3 (or .wav, depending on the file you're using) to your filenames.
Sponsor
Sponsor
Sponsor
sponsor
SNIPERDUDE




PostPosted: Tue Mar 30, 2010 12:05 pm   Post subject: RE:two questions

Incorrect, AC/DC is the greatest band ever. Razz
USEC_OFFICER




PostPosted: Tue Mar 30, 2010 3:34 pm   Post subject: RE:two questions

Do you really need seperate strings for each answer? tt doesn't seem to do anything as well. Just pointing that out.
DemonWasp




PostPosted: Tue Mar 30, 2010 8:00 pm   Post subject: RE:two questions

Apparently people who are 16 years old are in the "15 and younger" age group.
USEC_OFFICER




PostPosted: Tue Mar 30, 2010 8:10 pm   Post subject: RE:two questions

How can you be the greatest man alive, and barney is the greatest person ever? There, I've run circles around you logically.
SNIPERDUDE




PostPosted: Tue Mar 30, 2010 9:13 pm   Post subject: RE:two questions

Maybe a quiz with better questions and a four options per question would have been better. But rather than dwell on past projects of such simplicity try expanding your current know-how. Why not try some graphics?
USEC_OFFICER




PostPosted: Wed Mar 31, 2010 11:43 am   Post subject: RE:two questions

How about a simple scrolling game to start out with? It's very simple, yet looks good and professional.
4sak3nX




PostPosted: Wed Mar 31, 2010 1:07 pm   Post subject: RE:two questions

first off this isnt suposed to be logical. I mad it like this. Second its for school so all you are saying about what i should add content wise is completely wasted. It won change. Thank you for the help about the sound though.
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  [ 18 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: