Problem

Given the program below, what is the output if the user enters “one” in response to the pr...

Given the program below, what is the output if the user enters “one” in response to the prompt?

/************************************************************** FantasyFootball.java* Dean&Dean** This prints out names of football players.*************************************************************/import java.util.Scanner;import java.util.ArrayList;public class FantasyFootball{   public static void main(String[] args)   {      Scanner stdIn = new Scanner(System.in);      ArrayList<String> players = new ArrayList<>();      String indexStr;      int index = 0;      players.add("Aaron Rodgers");      players.add("Ray Rice");      players.add("Andrew Luck");      System.out.print("Enter a number between 1 and 3: ");      indexStr = stdIn.nextLine();      try      {        index = Integer.parseInt(indexStr);        System.out.println("Entered index OK.");      }      catch (NumberFormatException e)      {        System.out.println("Entered index wasn’t an integer");      }      try      {        System.out.println(players.get(index - 1));      }      catch (IndexOutOfBoundsException e)      {        System.out.println(        "Can’t access players[" + (index - 1) + "]");      }     System.out.println("done");   } // end main} // end class FantasyFootball

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 15
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT