Complete method simulate below. You must use hopDistance appropriately to receive full credit. /** Simulates a frog attempting to reach the goal as described in part (a).

  • Returns true if the frog successfully reached or passed the goal during the simulation;
  • false otherwise. */ public boolean simulate()
public boolean simulate(){
    int pos = 0;
    for (int hop = 0; hop < maxHops; hop++){
        pos = pos + hopDisyance();
        if (pos >= goalDistance){
            return true;
        }
        else if (pos < 0){
            return false;
        }
    }
    return false;
}
public double runSimulations(int num){
    double success = 0;
    for (int run = 0; run < num; run++){
        if (simulate()){
            success++;
        }
    }
    return success / num
}