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

Username:   Password: 
 RegisterRegister   
 Heres my program for grade 11 programming (1st project)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
shadow47607




PostPosted: Thu Oct 19, 2006 7:59 am   Post subject: Heres my program for grade 11 programming (1st project)

my class is writing a hi-lo-game and we need to make it 2 players

if i could get some help i would greatly appreciate it

heres the code:

code:
%Terry Whitlow
%October 19, 2006
process DoMusic
    loop
        Music.PlayFile ("M:/My Music/Mario.mp3")
    end loop
end DoMusic
fork DoMusic
for i : 1 .. 200
    locate (20, 20)
    drawoval (i, i, i, i, i)
    delay (10)
    put "WELCOME TO TERRY'S HIGH AND LOW GAME, ENJOY YOURSELF"
end for
delay (5)
drawfillbox (0, 0, 640, 400, 175)
put "LOADING...PLEASE WAIT FOR THE GAME TO LOAD"
delay (1000)
drawfillbox (0, 0, 640, 400, 0)
var playAgain, difficulty, userName : string
var numGuess, timeRunning, userGuess, randNum, n1, n2 : int
put "What is your name?"
get userName
put "Welcome ", userName, "."
loop
    put "Please enter the difficulty you want, (e)asy, (m)edium, (h)ard, or (c)ustom."
    get difficulty
    if difficulty = "e" then
        randint (randNum, 1, 10)
        put "EASY DIFFICULTY--Please guess the number I am thinking between 1 and 10."
    elsif difficulty = "m" then
        randint (randNum, 1, 100)
        put "MEDIUM DIFFICULTY--Please guess the number I am thinking between 1 and 100."
    elsif difficulty = "h" then
        randint (randNum, 1, 1000)
        put "HARD DIFFICULTY--Please guess the number I am thinking between 1 and 1000."
    elsif difficulty = "c" then
        put "Type the number you want as the lowest"
        get n1
        put "Type the number you want as the highest"
        get n2
        randint (randNum, n1, n2)
        put "CUSTOM DIFFICULTY--Please guess the number I am thinking between the 2 numbers you chose, which are ", n1, " and ", n2, "."
    end if
    numGuess := 0
    loop
        get userGuess
        if userGuess = randNum then
            put "Congratulations, ", userName, ", you have outsmarted me"
            numGuess := numGuess + 1
        elsif userGuess < randNum then
            put "Too low, try again"
            numGuess := numGuess + 1
        elsif userGuess > randNum then
            put "Too high, try again"
            numGuess := numGuess + 1
        end if
        exit when userGuess = randNum
    end loop
    timeRunning := Time.Elapsed
    put "This has taken you ", numGuess, " guess('s)"
    put "This has taken you ", timeRunning / 1000, " seconds"
    put "Thanks for playing"
    put "Would you like to play again?(y)es , (n)o."
    get playAgain
    exit when playAgain = "n"
end loop
loop
    drawfillbox (0, 0, 640, 400, 175)
    put "THANK YOU FOR PLAYING, PLEASE PLAY AGAIN"
    delay (2500)
end loop
Sponsor
Sponsor
Sponsor
sponsor
frank26080115




PostPosted: Sat Oct 21, 2006 1:43 am   Post subject: (No subject)

im a noob so i dont know how to help you, but the time in seconds it's giving me is wrong
Ultrahex




PostPosted: Tue Oct 24, 2006 7:44 pm   Post subject: (No subject)

This is probably long gone now, but your use of the Time.Elapsed is wrong, you are checking the time from the start of running the program till when you check it.

Therefore its not reset on start of hitting easy, and its not reset on play again.

You will need a start time and end time and compare them to get how long.
do_pete




PostPosted: Wed Oct 25, 2006 8:38 am   Post subject: (No subject)

What exactly is it that you need help with? Oh, and get rid of that "loading" thing because you're not loading anything and it's anoying.
Mathwiz




PostPosted: Tue Oct 31, 2006 8:56 am   Post subject: Re: Heres my program for grade 11 programming (1st project)

tha was coolk


shadow47607 wrote:
my class is writing a hi-lo-game and we need to make it 2 players

if i could get some help i would greatly appreciate it

heres the code:

code:
%Terry Whitlow
%October 19, 2006
process DoMusic
    loop
        Music.PlayFile ("M:/My Music/Mario.mp3")
    end loop
end DoMusic
fork DoMusic
for i : 1 .. 200
    locate (20, 20)
    drawoval (i, i, i, i, i)
    delay (10)
    put "WELCOME TO TERRY'S HIGH AND LOW GAME, ENJOY YOURSELF"
end for
delay (5)
drawfillbox (0, 0, 640, 400, 175)
put "LOADING...PLEASE WAIT FOR THE GAME TO LOAD"
delay (1000)
drawfillbox (0, 0, 640, 400, 0)
var playAgain, difficulty, userName : string
var numGuess, timeRunning, userGuess, randNum, n1, n2 : int
put "What is your name?"
get userName
put "Welcome ", userName, "."
loop
    put "Please enter the difficulty you want, (e)asy, (m)edium, (h)ard, or (c)ustom."
    get difficulty
    if difficulty = "e" then
        randint (randNum, 1, 10)
        put "EASY DIFFICULTY--Please guess the number I am thinking between 1 and 10."
    elsif difficulty = "m" then
        randint (randNum, 1, 100)
        put "MEDIUM DIFFICULTY--Please guess the number I am thinking between 1 and 100."
    elsif difficulty = "h" then
        randint (randNum, 1, 1000)
        put "HARD DIFFICULTY--Please guess the number I am thinking between 1 and 1000."
    elsif difficulty = "c" then
        put "Type the number you want as the lowest"
        get n1
        put "Type the number you want as the highest"
        get n2
        randint (randNum, n1, n2)
        put "CUSTOM DIFFICULTY--Please guess the number I am thinking between the 2 numbers you chose, which are ", n1, " and ", n2, "."
    end if
    numGuess := 0
    loop
        get userGuess
        if userGuess = randNum then
            put "Congratulations, ", userName, ", you have outsmarted me"
            numGuess := numGuess + 1
        elsif userGuess < randNum then
            put "Too low, try again"
            numGuess := numGuess + 1
        elsif userGuess > randNum then
            put "Too high, try again"
            numGuess := numGuess + 1
        end if
        exit when userGuess = randNum
    end loop
    timeRunning := Time.Elapsed
    put "This has taken you ", numGuess, " guess('s)"
    put "This has taken you ", timeRunning / 1000, " seconds"
    put "Thanks for playing"
    put "Would you like to play again?(y)es , (n)o."
    get playAgain
    exit when playAgain = "n"
end loop
loop
    drawfillbox (0, 0, 640, 400, 175)
    put "THANK YOU FOR PLAYING, PLEASE PLAY AGAIN"
    delay (2500)
end loop
shadow47607




PostPosted: Thu Nov 02, 2006 2:21 pm   Post subject: (No subject)

i needed help making it 2 player and with getting the time to work properly
bruized




PostPosted: Thu Nov 02, 2006 7:39 pm   Post subject: (No subject)

To make it two player, every time the first user has had his guess then ask the second user to guess. It's actually quite simple. If you're not sure what I mean than just ask. I'll leave the rest up to your imagination, unless you're still having troubles.

Now for the time part. The problem is that the time you have it took the user to guess the number is since the beginning when the user started running the program. To eliminate this, take the time.elapsed when the user starts guessing the number and then at the end. Then find the difference between the two numbers and presto!, you have the amount of time it took the user to guess the number.

And on a side note, to calculate the amount of seconds your formula is wrong. You divide by a thousand to get the amount of seconds. However in a second there is only a 100 milliseconds.

Make these changes and it will work. I already tried.
Clayton




PostPosted: Fri Nov 03, 2006 8:01 am   Post subject: (No subject)

bruized wrote:

And on a side note, to calculate the amount of seconds your formula is wrong. You divide by a thousand to get the amount of seconds. However in a second there is only a 100 milliseconds.


Wow, I knew the day got shorter last Sunday, but losing 900 milliseconds off of every second? That's impressive.

Seriously though, he's right bruized, there are 1000 milliseconds in a second.
Sponsor
Sponsor
Sponsor
sponsor
bruized




PostPosted: Fri Nov 03, 2006 3:57 pm   Post subject: (No subject)

What?! There's a thousand milliseconds in a second. Oops, sorry. I could've sworn it was one hundred. Anyways, sorry about that (people make mistakes you know Razz , good thing this is a forum otherwise I would've been so embarrased).

An another side note, how come certain watches show milliseconds but they only have two number instead of three? I guess that's what made me think there was 100 ms in a s. that plus there's 100 mm in 1 cm except cm aren't the base unit so I see where I went wrong. I hope I didn't make any other mistakes Embarassed
rdrake




PostPosted: Fri Nov 03, 2006 4:04 pm   Post subject: (No subject)

bruized wrote:
What?! There's a thousand milliseconds in a second. Oops, sorry. I could've sworn it was one hundred. Anyways, sorry about that (people make mistakes you know Razz , good thing this is a forum otherwise I would've been so embarrased).

An another side note, how come certain watches show milliseconds but they only have two number instead of three? I guess that's what made me think there was 100 ms in a s. that plus there's 100 mm in 1 cm except cm aren't the base unit so I see where I went wrong. I hope I didn't make any other mistakes Embarassed
Let's clear some things up here. There are 10 mm in 1 cm, there are 100 cm in 1 m.

As for time, there are 1000 milliseconds in a second, 60 seconds in a minute, 60 minutes in an hour, and 24 hours in a day.

Make sense?
bruized




PostPosted: Tue Nov 07, 2006 8:14 pm   Post subject: (No subject)

rdrake wrote:
Let's clear some things up here. There are 10 mm in 1 cm, there are 100 cm in 1 m.

As for time, there are 1000 milliseconds in a second, 60 seconds in a minute, 60 minutes in an hour, and 24 hours in a day.

Make sense?


Yes, it does make sense, I knew that (except for the milliseconds part I kept getting it wrong) but anyways, I had a little typo in my last post. I'm not that stupid Rolling Eyes Laughing I meant to put 10 mm but accidentally added an extra zero. Just a big mix up. I know these things.
helpyourselfhelpsomeoneel




PostPosted: Tue Nov 14, 2006 10:39 am   Post subject: help

in my school thpat would falle in a grade 11
TokenHerbz




PostPosted: Tue Nov 14, 2006 11:28 am   Post subject: (No subject)

Ok, i thought I had a big aviator befor...

but helpyourselfhelpsomeoneel, your is retardedly huge....

Shring him asap, befor a dev sees it.
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  [ 13 Posts ]
Jump to:   


Style:  
Search: