Процент штрафной программы - PullRequest
0 голосов
/ 28 сентября 2019

У меня проблема с последней частью этой программы.

Пользователь вводит процент и генерирует 5 случайных игр по 10 штрафных бросков.Он должен отображать, сколько штрафных бросков было сделано в лучшей игре из 5, и сколько штрафных бросков было пропущено в худшей игре из 5. Я настроил его, чтобы запрашивать у пользователя процент, и он будет генерироваться случайным образом.5 игр в зависимости от процента, вложенного в

import java.util.Scanner;
import java.util.Random;
public class Final2 {
   public static void main(String[] args) {
      //Create input scanner for shooter percentage
      Scanner input = new Scanner(System.in);
      System.out.print("Enter Player's Free Throw Percentage: ");
      int percent = input.nextInt();
      int inCount = 0;

      // game and total make/miss counts
      int outCount = 0;
      int Game1 = 0;
      int Game2 = 0;
      int Game3 = 0;
      int Game4 = 0;
      int Game5 = 0;

      // Game  random num compared to user input percent and count for game and total
      System.out.println("Game 1:");
      Random r = new Random();
      for (int i = 0; i < 10; ++i){
         int randomInt = r.nextInt(100);
         if (percent >= randomInt)
         {
            System.out.print("In" + " ");
            inCount++;
            Game1++;
         }
         if (percent < randomInt)
         {
            System.out.print("Out" + " ");
            outCount++;
         }
      }
      System.out.println();
      System.out.println("Free throws made: " + Game1 + " out of 10.");

      // Game random num compared to user input percent and count for game and total

      System.out.println("");
      System.out.println("Game 2:");
      Random r2 = new Random();
      for (int i = 0; i < 10; ++i){
         int randomInt = r2.nextInt(100);
         if (percent >= randomInt)
         {
            System.out.print("In" + " ");
            inCount++;
            Game2++;
         }
         if (percent < randomInt)
         {
            System.out.print("Out" + " ");
            outCount++;
         }
      }
      System.out.println();
      System.out.println("Free throws made: " + Game2 + " out of 10.");
      System.out.println("");

      // Game random num compared to user input percent and count for game and total
      System.out.println("");
      System.out.println("Game 3:");
      Random r3 = new Random();
      for (int i = 0; i < 10; ++i){
         int randomInt = r3.nextInt(100);
         if (percent >= randomInt)
         {
            System.out.print("In" + " ");
            inCount++;
            Game3++;
         }
         if (percent < randomInt)
         {
            System.out.print("Out" + " ");
            outCount++;
         }
      }
      System.out.println();
      System.out.println("Free throws made: " + Game3 + " out of 10.");
      System.out.println("");

      // Game  random num compared to user input percent and count for game and total
      System.out.println("");
      System.out.println("Game 4:");
      Random r4 = new Random();
      for (int i = 0; i < 10; ++i){
         int randomInt = r4.nextInt(100);
         if (percent >= randomInt)
         {
            System.out.print("In" + " ");
            inCount++;
            Game4++;
         }
         if (percent < randomInt)
         {
            System.out.print("Out" + " ");
            outCount++;
         }
      }


      System.out.println();
      System.out.println("Free throws made: " + Game4 + " out of 10.");
      System.out.println("");

      // Game  random num compared to user input percent and count for game and total
      System.out.println("");
      System.out.println("Game 5:");
      Random r5 = new Random();
      for (int i = 0; i < 10; ++i){
         int randomInt = r5.nextInt(100);
         if (percent >= randomInt)
         {
            System.out.print("In" + " ");
            inCount++;
            Game5++;
         }
         if (percent < randomInt)
         {
            System.out.print("Out" + " ");
            outCount++;
         }
      }


      System.out.println();
      System.out.println("Free throws made: " + Game5 + " out of 10.");
      System.out.println("");

      System.out.println("Summary:");
      //System.out.println("Best Game Free Throws Made:" + );
      //System.out.println("Worst Game Free Throws Made:");
      System.out.println("Total Free Throws Made: " + (50-outCount) + " " + "out of 50");
      System.out.println("Average Free Throw Percentage:" + (inCount*2) +"%");
   }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...