BrandNewDay's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
10 (0.02 per day)
Joined:
09-October 11
Profile Views:
192
Last Active:
User is offline Mar 12 2012 07:42 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   BrandNewDay has not set their status

Posts I've Made

  1. In Topic: error: cannot find symbol Math.Random();

    Posted 10 Mar 2012

    Can you post your entire code so we can trace it?
  2. In Topic: Can't loop

    Posted 10 Mar 2012

    No I can't input a new value for choice because the statements after the do-while loop directly executes.

    do{ 
         ...       
    }while(choice == 'y' || choice == 'Y');
    System.out.println("\nFREQUENCY:\nHeads: " + heads + "\nTails: " + tails); //this part directly executes without letting me input another value for choice.
    
    


    So basically, after just inputting 'y' once, I get the following output:

    TOSS COIN? Press y for yes.y
    TAIL
    TOSS COIN? Press y for yes.
    FREQUENCY:
    Heads: 0
    Tails: 1
    
    
  3. In Topic: Can't loop

    Posted 10 Mar 2012

    It doesn't display a compile-time error. But for instance, if the user types in y, the first loop would execute and then since the value of choice is still 'y', it's supposed to loop again. But instead, it just displays "TOSS COIN? Press y for yes." without asking for a new value of choice.
  4. In Topic: Can't loop

    Posted 10 Mar 2012

    Value of y after first loop is still while so the loop should continue but it's not.

    I mean to say, calue of choice is still while after first loop. so it's supposed to continue looping.

    *value of choice is still y after first loop so it should continue looping
  5. In Topic: Can't loop

    Posted 10 Mar 2012

    The problem is that this part of the code doesn't loop the way it's supposed to.

    do{
                System.out.print("TOSS COIN? Press y for yes.");
                choice = (char)System.in.read();
                if(choice == 'y' || choice == 'Y')
                {
                    Coins c = Coins.flip();
                    System.out.println(c);
                    if(c == Coins.HEAD)
                        heads++;
                    else
                        tails++;
                }
            }while(choice == 'y' || choice == 'Y');
    
    

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

BrandNewDay hasn't added any friends yet.

Comments

BrandNewDay has no profile comments yet. Why not say hello?