Hope this question makes sense but essentially here is the issue I am having. I am tasked to create a program that takes someone's free throw shooting percentage as an input then simulates 5 games where they attempt to shoot 10 free throws each game. As well as have a summary afterward showing things like best game, worst game, total made through all games, and average free throw percentage.
I currently have up to the point where I am trying to make my simulated game run multiple times but cant seem to figure it out. This is what I have so far: import java.util.*;
public class FreeThrow {
public static int simulate(int input){
int i;
int j;
int count = 0;
for (j = 1; j < 6; j++){
System.out.println("Game " + j + ":");
for(i = 0;i < 10; i++){
int shot = (int)(Math.random()*101)-1;
if (shot > input){
System.out.print("OUT ");//shot missed
} else {
System.out.print("IN ");//shot made
count++;
}
}
//prints the number of free throws made per game out of 10
System.out.print("\nFree throws made: " + count + " out of 10.");
return i;
}
return j;
}
public static void main (String[] args){
//asks for user input to detemine player free throw percentage
Scanner scan = new Scanner(System.in);
System.out.print("Enter Player's Free Throw Percentage: ");
int input = scan.nextInt();
simulate(input);
}
}
As you can see I currently have a for loop inside a for loop. I did this to try to make the simulated game loop loop itself again while adding the "Game 1:" line that would display above and show what game each was. It works perfectly for just one Game. I have it looking exactly like it should. As well here is an example of what the professor wants it to look like:Link To Image Any sort of insight on what I might be doing wrong or suggestions on how to get it to do what I would like would be greatly appreciated.