Answered step by step
Verified Expert Solution
Question
1 Approved Answer
below is my Java code please help me with exception handing where input is negative and greater than 8 __________________________________________ import java.util.Scanner; import java.util.Random; public
below is my Java code please help me with exception handing where input is negative and greater than 8 __________________________________________ import java.util.Scanner; import java.util.Random; public class main { //Static and final class member called _ with a value of 8 private static final int Max_PLAYS =8; //landing obejct private int landings[]; /** * this is main methoad for runinig simulatePlay * @param play * Using Javas random number generator class, generate a random number to simulate the throw of the ball. * */ public void simulatePlay(int play ){ int hallValue, n; Random randnNum = new Random(); // set landing to new array landings = new int[play]; // for loop for play for(int i=1; i=6 && n =16 && n =31 && n =46 && n Max_PLAYS); main object = new main(); object.simulatePlay(play); object.showStats(); sc.close(); } }Figures: Enter the number of plays (1-8)? O Invalid input. Please enter a number between 1 and 8. Enter the number of plays (1-8)? -1 Invalid input. Please enter a number between 1 and 8. Enter the number of plays (1-8)? 100 Invalid input. Please enter a number between 1 and 8. Enter the number of plays (1-8)? Figure 2: Invalid entry message and re-prompt Enter the number of plays (1-8)? 5 Rolling ball #1. Landed in o Rolling ball #2. Landed in 10 Rolling ball #3. Landed in 20 Rolling ball #4. Landed in 80 Rolling ball #5. Landed in 40
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started