Results 1 to 5 of 5
Thread: Help With program
- 10-07-2009, 04:55 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 3
- Rep Power
- 0
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);
}
}
}
- 10-07-2009, 08:19 AM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
What is the line
supposed to be declaring?Java Code:private boolean StoreFlips[] = new StoreFlips[100];
- 10-07-2009, 03:40 PM #3
Member
- Join Date
- Oct 2009
- Posts
- 3
- Rep Power
- 0
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
- 10-07-2009, 03:45 PM #4
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
So did you want to say
instead?Java Code:private boolean[] storeFlips = new boolean[100];
- 10-07-2009, 04:10 PM #5
Member
- Join Date
- Oct 2009
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Execute A program from a Program!
By Moncleared in forum Advanced JavaReplies: 2Last Post: 02-22-2009, 04:17 PM -
Executing a program within a program
By gibsonrocker800 in forum New To JavaReplies: 5Last Post: 05-12-2008, 08:24 AM -
How to execute an External Program through Java program
By Java Tip in forum java.ioReplies: 0Last Post: 04-04-2008, 02:40 PM -
How to execute an External Program through Java program
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:33 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks