Cora Dyce

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

Cora Dyce - Your personal dicing clan


    questions regarding to coding

    Share

    peasant
    Highroller
    Highroller

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

    Dices Rolls
    Dice Roll:

    questions regarding to coding

    Post by peasant on 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!
    avatar
    Allen's Slave
    Member
    Member

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

    Re: questions regarding to coding

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

    What language?
    avatar
    Allen's Slave
    Member
    Member

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

    Re: questions regarding to coding

    Post by Allen's Slave on 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!");
    }
    avatar
    Allen's Slave
    Member
    Member

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

    Re: questions regarding to coding

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

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

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

    Re: questions regarding to coding

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

    Allen's Slave wrote:What language?

    spanish
    avatar
    CM
    Sponsor
    Sponsor

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

    Re: questions regarding to coding

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

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

    spanish

    LOL
    avatar
    Slash
    Global Mod
    Global Mod

    Posts : 10742
    Join date : 2012-04-01
    Age : 21
    Location : Ali's computer

    Re: questions regarding to coding

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

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

    spanish

    LOL
    wow, so funnies.


    _________________

    By Shygodd <3
    Lel:









    avatar
    CM
    Sponsor
    Sponsor

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

    Re: questions regarding to coding

    Post by CM on 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.
    avatar
    Jon
    Sponsor
    Sponsor

    Posts : 13680
    Join date : 2011-09-19
    Age : 20
    Location : United Kingdom

    Dices Rolls
    Dice Roll:

    Re: questions regarding to coding

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

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

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

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

    Re: questions regarding to coding

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

    Do you still need the other one?

    Sponsored content

    Re: questions regarding to coding

    Post by Sponsored content


      Current date/time is 2017-09-25, 20:54