So I am in a CIS 111 course and I cannot figure out how to do this program. I am at the point now where I can read java and understand exactly what the program will do but still being able to think of what class/methods to call still boggles my mind. What I am trying to do in this program is this.
1. Flip the coin 100 times
2. I want it to keep track of the highest amount of heads flips in a row.
3. I want it to keep track of the highest amount of tails flips in a row.
at the end of the program I want it to print out the highest amount of heads flips in a row and tails flips in a row. I'm honestly not sure how to achieve this with the program I currently have altered. I could really use some help here and I figure someone here could help a noobie out .
public class Runs { public static void main (String[] args) { final int FLIPS = 100; // number of coin flips int currentRun = 0; // length of the current run of HEADS int currentRunTails = 1; int maxRunTails = 1; int maxRunHeads = 0; // length of the maximum run so far int lastflip; // I need the last flip before current flip then set current flip equal to last flip. int currentflip; // Create a coin object Coin myCoin = new Coin(); // creates coin object // Flip the coin FLIPS times for (int i = 0; i <= FLIPS; i++) // { // Flip the coin & print the result myCoin.flip(); System.out.println(myCoin); currentflip = ; lastflip = currentflip; // Update the run information if (myCoin.getFace() == 0) { currentRun++; // currentRunTails++; // If we keep getting heads in a row it will add 1 to each time before we got heads. if (currentRun > maxRunHeads) maxRunHeads = currentRun; // currentRun = 0; }//ends the if else //we just threw a TAILS currentRunTails++; if (currentRunTails > maxRunTails) maxRunTails = currentRunTails; }//ends the for // Print the results System.out.println("The highest amount of HEADS in a row we have gotten is: " + maxRunHeads); System.out.println("The highest amount of TAILS in a row we have gotten is: " + maxRunTails); }//ends the main }// ends the runs class