Cora Dyce

Welcome to our website !
Please register an account to view the complete categories and forums.


Join the forum, it's quick and easy

Cora Dyce

Welcome to our website !
Please register an account to view the complete categories and forums.

Cora Dyce

Would you like to react to this message? Create an account in a few clicks or log in to continue.

Cora Dyce - Your personal dicing clan


+2
Allen's Slave
peasant
6 posters

    questions regarding to coding

    avatar
    peasant
    Highroller
    Highroller


    Posts : 590
    Join date : 2011-06-20
    Age : 27

    Dices Rolls
    Dice Roll:

    questions regarding to coding Empty questions regarding to coding

    Post by peasant 2014-03-24, 03:43

    Having problems with these questions...

    Write a method named hopscotch that accepts an integer parameter for a number of "hops" and prints a hopscotch board of that many hops. A "hop" is defined as the split into two numbers and then back together again into one. For example, hopscotch(3); should print:

    1
    2 3
    4
    5 6
    7
    8 9
    10

    Write a method named threeHeads that repeatedly flips a coin until three heads in a row are seen. You should use a Random object to give an equal chance to a head or a tail appearing. Each time the coin is flipped, what is seen is displayed (H for heads, T for tails). When 3 heads in a row are flipped a congratulatory message is printed. Here are possible outputs of two calls to threeHeads:

    T T T H T H H H
    Three heads in a row!

    thanks!
    Allen's Slave
    Allen's Slave
    Member
    Member


    Posts : 4445
    Join date : 2012-08-09
    Age : 30
    Location : A$AP

    questions regarding to coding Empty Re: questions regarding to coding

    Post by Allen's Slave 2014-03-24, 05:52

    What language?
    Allen's Slave
    Allen's Slave
    Member
    Member


    Posts : 4445
    Join date : 2012-08-09
    Age : 30
    Location : A$AP

    questions regarding to coding Empty Re: questions regarding to coding

    Post by Allen's Slave 2014-03-24, 06:00

    Assuming it's Java:

    public static void threeHeads(){
    Random r = new Random();
    int i = 0;
    while(i < 3){
    if((r.nextInt(2) + 1) == 1){
    System.out.print("H ");
    i++;
    }
    else{
    System.out.print("T ");
    i = 0;
    }
    }
    System.out.println();
    System.out.println("Three heads in a row!");
    }
    Allen's Slave
    Allen's Slave
    Member
    Member


    Posts : 4445
    Join date : 2012-08-09
    Age : 30
    Location : A$AP

    questions regarding to coding Empty Re: questions regarding to coding

    Post by Allen's Slave 2014-03-24, 06:01

    Additionally, no idea what you're talking about with your hopstoch() method. Could you explain it more?
    Tom's Slave
    Tom's Slave
    VIP
    VIP


    Posts : 4757
    Join date : 2012-05-12
    Age : 28
    Location : Mac and Cheese

    questions regarding to coding Empty Re: questions regarding to coding

    Post by Tom's Slave 2014-03-24, 07:55

    Allen's Slave wrote:What language?

    spanish
    CM
    CM
    Sponsor
    Sponsor


    Posts : 4530
    Join date : 2012-03-29
    Location : https://www.youtube.com/watch?v=cB6ueuLb8Gc

    questions regarding to coding Empty Re: questions regarding to coding

    Post by CM 2014-03-24, 15:45

    Tom's Slave wrote:
    Allen's Slave wrote:What language?

    spanish

    LOL
    Slash
    Slash
    Global Mod
    Global Mod


    Posts : 10756
    Join date : 2012-04-01
    Age : 28
    Location : Ali's computer

    questions regarding to coding Empty Re: questions regarding to coding

    Post by Slash 2014-03-24, 15:48

    CM wrote:
    Tom's Slave wrote:
    Allen's Slave wrote:What language?

    spanish

    LOL
    wow, so funnies.
    CM
    CM
    Sponsor
    Sponsor


    Posts : 4530
    Join date : 2012-03-29
    Location : https://www.youtube.com/watch?v=cB6ueuLb8Gc

    questions regarding to coding Empty Re: questions regarding to coding

    Post by CM 2014-03-24, 15:52

    Slash wrote:
    CM wrote:
    Tom's Slave wrote:
    Allen's Slave wrote:What language?

    spanish

    LOL
    wow, so funnies.

    I actually meant: Lots of Love.
    Jon
    Jon
    Sponsor
    Sponsor


    Posts : 13685
    Join date : 2011-09-19
    Age : 28
    Location : United Kingdom

    Dices Rolls
    Dice Roll:

    questions regarding to coding Empty Re: questions regarding to coding

    Post by Jon 2014-03-24, 19:25

    Tom's Slave wrote:
    Allen's Slave wrote:What language?

    spanish
    bitch beat me to it >.<
    Allen's Slave
    Allen's Slave
    Member
    Member


    Posts : 4445
    Join date : 2012-08-09
    Age : 30
    Location : A$AP

    questions regarding to coding Empty Re: questions regarding to coding

    Post by Allen's Slave 2014-03-25, 23:00

    Do you still need the other one?

    Sponsored content


    questions regarding to coding Empty Re: questions regarding to coding

    Post by Sponsored content


      Current date/time is 2024-11-18, 08:47