Results 1 to 5 of 5
  1. #1
    schmo is offline Member
    Join Date
    Oct 2009
    Posts
    3
    Rep Power
    0

    Default Help With program

    Hello, im writing a program for school and i keep getting a lot of error based around"cannot find the symbol"
    "double Res= Math.random();"
    Res is already defined in
    Do i have to make the 2nd res ..res2?
    private boolean StoreFlips[] = new StoreFlips
    It says it cant find the symbol

    and goes on ...it cant find the symbols for
    longestrun head and max
    im missing a bracket somewhere? or what






    public class CoinFlip
    {
    private int CountHead = 0;
    private int CountTail = 0;
    private int LongestRunHeads = 0;
    private int MaxLongestRunHeads = 0;
    private boolean StoreFlips[] = new StoreFlips[100];

    {


    for (int c = 0 ; c < 100;c++)
    {
    double Res = Math.random();
    if(Res < 5)
    {
    StoreFlips[c]= false;
    }

    else
    {
    StoreFlips[c]= true;
    }

    {
    System.out.println(StoreFlips[c]);

    }


    {
    for (int i =0;i > .5;i++)
    {
    double Res2 = Math.random();


    if ((Res2 >=0)&&(Res2 <.5))

    {
    System.out.print("Tails ");
    ++CountTail;
    LongestRunHeads = 0;
    }
    else
    {
    System.out.print("Heads ");
    ++CountHead;
    ++LongestRunHeads;

    if (LongestRunHeads > MaxLongestRunHeads)
    {

    MaxLongestRunHeads = LongestRunHeads;
    }




    System.out.println("\n\n" +" Head count is " + CountHead + " Tails count is " + CountTail );
    System.out.println("Longest Heads Count is: " + MaxLongestRunHeads);
    }
    }
    }

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    What is the line

    Java Code:
    private boolean StoreFlips[] = new StoreFlips[100];
    supposed to be declaring?

  3. #3
    schmo is offline Member
    Join Date
    Oct 2009
    Posts
    3
    Rep Power
    0

    Default

    i need to have one boolean statement to store the array of all the coin flips
    basically the program is ..it randomly picked heads or tails
    and i need to seee how many heads and how many tails show
    and report the longest run of heads
    i thought i have a boolean statement to store the value and keep track of it

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    So did you want to say
    Java Code:
    private boolean[] storeFlips = new boolean[100];
    instead?

  5. #5
    schmo is offline Member
    Join Date
    Oct 2009
    Posts
    3
    Rep Power
    0

    Default

    thank you, that fixed it! damn i spent 2 hours looking and trying to fix it lol

Similar Threads

  1. Execute A program from a Program!
    By Moncleared in forum Advanced Java
    Replies: 2
    Last Post: 02-22-2009, 04:17 PM
  2. Executing a program within a program
    By gibsonrocker800 in forum New To Java
    Replies: 5
    Last Post: 05-12-2008, 08:24 AM
  3. Replies: 0
    Last Post: 04-04-2008, 02:40 PM
  4. Replies: 0
    Last Post: 10-04-2007, 09:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •