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

Username:   Password: 
 RegisterRegister   
 coin flip program for school project
Index -> Programming, Turing -> Turing Submissions
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
drumersrule123




PostPosted: Fri Dec 12, 2003 8:56 pm   Post subject: coin flip program for school project

code:

var ht : string (1)                     % Your guess either heads or tails
var heads : string := "h"               % It sands for the heads side of the coin you type h for heads
var tails : string := "t"               % It sands for the tails side of the coin you type t for tails
var answer : int                        % The varible that chooses heads or tails
var coin : string                       % Coin is the coin and is used to distinguish heads or tails
var score: int := 0                     % The score helps keep score
var counter : int := 0                  % The counter so it will exit when it lands on heads or tails 15 times
randomize
put "Enter h for heads or t for tails"

loop



    randint (answer, 1, 2)

    if answer = 1 then
        coin := heads
    else
        coin := tails
    end if
    put " "
    put "I've flipped a coin. Is it H)eads or T)ails?" ..

    getch (ht)
    put " "
    put ""


    if ht = coin then
        score := score + 10
       
        put "Correct! Your score is ", score
        put ""
    elsif ht = "t" then
        score := score - 10
        put "Wrong! Your score is ", score
        put " "

   elsif ht = "h" then
        score := score - 10
        put "Wrong! Your score is ", score
        put " "
    else
        put "Incorrect input"
        put " "
    end if
    if ht = "h" or ht = "t" then
        counter := counter + 1
    end if
    exit when counter = 15

end loop
put " "
put "Your final score is ", score ..
put " "


dosen't have coin here is what i started for coin

code:

setscreen ("graphics:vga")
setscreen ("nocursor")
cls
const xradius := 35
var coin : int := 0
var x, y, ydir, xdir, speed : int
x := maxx div 2
y := maxy div 2
xdir := 1
ydir := - 1
speed := 15
loop
for t: 1 .. 25
    coin := coin + 1
   if coin = 35 then
   put
    coin = coin - 1
    end if
    drawfilloval (x, y, xradius, coin, yellow)
    delay (8)
    cls
end for
for c: 1 .. 25
    coin := coin - 1
   if coin = 35 then
   put
    coin = coin + 1
    end if
    drawfilloval (x, y, xradius, coin, yellow)
    delay (8)
    cls
end for
end loop
Sponsor
Sponsor
Sponsor
sponsor
drumersrule123




PostPosted: Fri Dec 12, 2003 10:32 pm   Post subject: (No subject)

if any has any idea for making the coin move up and back down plz share Very Happy
McKenzie




PostPosted: Fri Dec 12, 2003 11:25 pm   Post subject: (No subject)

drummer,

no one has responeded because they don't have a clue what you are asking. You have posted some code (include it intsead), but not made it clear,
a) what problem you are having
b) how you would like to improve your code.
The guys here are more than happy to help, but you gotta make it clear what kinda help you need.
Thuged_Out_G




PostPosted: Fri Dec 12, 2003 11:32 pm   Post subject: (No subject)

and get ridda your pic...its huge and meeses up the whole page...ill read your code when the pic is gone, and its not a huge block of code with like 3 words per line

btw, you shouldnt be asking for help/suggestions in the submissions forum
poly




PostPosted: Fri Dec 12, 2003 11:36 pm   Post subject: (No subject)

Quote:
if any has any idea for making the coin move up and back down plz share

well i think he wants his coin (second part of code that isnt in white) to go up and down like your really flipping a coin.
santabruzer




PostPosted: Fri Dec 12, 2003 11:38 pm   Post subject: (No subject)

just sub for statements for the y co-ordinate.. that's simple enough

i dunnu.. you can modify this:
code:

setscreen ("offscreenonly")
setscreen ("nocursor")
cls
const xradius := 35
var coin : int := 0
var x, ydir, xdir, speed : int
x := maxx div 2
xdir := 1
ydir := -1
speed := 15

procedure coinflip (y : int)

    for t : 1 .. 25
        coin := coin + 1
        if coin = 35 then
            put
                coin = coin - 1
        end if
        drawfilloval (x, y, xradius, coin, yellow)
        delay (5)
        View.Update
        cls
    end for
    for c : 1 .. 25
        coin := coin - 1
        if coin = 35 then
            put
                coin = coin + 1
        end if
        drawfilloval (x, y, xradius, coin, yellow)
        delay (1)
        View.Update
        cls
    end for

end coinflip

loop
    for y : 1 .. 200 by 10
        coinflip (y)
    end for
    for decreasing y : 200 .. 1 by 10
        coinflip (y)
    end for
end loop
Andy




PostPosted: Sat Dec 13, 2003 5:23 pm   Post subject: (No subject)

here is an improved version of santabruzer's code
code:
setscreen ("offscreenonly")
const xradius := 35
var xpos := maxx div 2
var height, radius := 1
var dir, side := 1

process vertical
    loop
        if height = maxy or height = 0 then
            dir := -dir
        end if
        height += 1 * dir
    end loop
end vertical

process flip
    loop
        if radius = 50 or radius = 0 then
            side := -side
        end if
        radius += side
    end loop
end flip

fork vertical
fork flip
loop
    drawfilloval (xpos, height, 50, radius, brown)
    View.Update
    cls
end loop
santabruzer




PostPosted: Sat Dec 13, 2003 9:15 pm   Post subject: (No subject)

dodge_tomahawk wrote:
code:
        height += 1 * dir
   


Seriously.. why couldn't you make taht
code:
height += dir
... added 2 extra characters... i'm suprised..
Sponsor
Sponsor
Sponsor
sponsor
AsianSensation




PostPosted: Sat Dec 13, 2003 9:17 pm   Post subject: (No subject)

tsk tsk dodge, you've written some source code, but it doesnt have whatdotcolor in it......

and you call yourself the whatdotcolor warrior?

Razz
santabruzer




PostPosted: Sat Dec 13, 2003 9:18 pm   Post subject: (No subject)

look at us.. tearing apart his code... Razz
DanShadow




PostPosted: Sat Dec 13, 2003 9:33 pm   Post subject: (No subject)

Woah...is this post messed or is it just me? All the text is like 1 screenlength to the right. GET RID OF THAT PIC Drumersrule123! Its keeling us all.
Mazer




PostPosted: Sat Dec 13, 2003 9:47 pm   Post subject: (No subject)

DanShadow wrote:
Woah...is this post messed or is it just me? All the text is like 1 screenlength to the right. GET RID OF THAT PIC Drumersrule123! Its keeling us all.

what are you people talking about? drummersrule's pic is fine! i've seen much larger on this site. the problem is some bug with the forum or something like that. tell dan about it
DanShadow




PostPosted: Sat Dec 13, 2003 10:39 pm   Post subject: (No subject)

Ill pm Dan about it...
Oh and sorry, thought the pic was screwy
Mazer




PostPosted: Sat Dec 13, 2003 11:08 pm   Post subject: (No subject)

DanShadow wrote:
thought the pic was screwy

ok, but why? am i missing something, because it looks fine to me. just a (fair sized) pic of bart simpson...
Thuged_Out_G




PostPosted: Sun Dec 14, 2003 1:13 am   Post subject: (No subject)

i beleive when the post was made, his picture was much larger, and then after he changed his picture....there isnt any bug in the forum
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 19 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: