Question: For the program in Exercise 1, what is the output if the user enters first in response to the prompt? Exercise 1 Given the program
For the program in Exercise 1, what is the output if the user enters “first” in response to the prompt?
Exercise 1
Given the program below, what is the output if the user enters 3 in response to the prompt?
![import java.util.Scanner; public class Athletes { public static void main(String[] args) { Scanner stdIn](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1704/8/8/5/199659e7bcfe87e11704885197124.jpg)
import java.util.Scanner; public class Athletes { public static void main(String[] args) { Scanner stdIn String[] players {"Serena Williams", "Alex Morgan", " Allyson Felix", "Lindsey Vonn", "Katie Ledecky"); String ranking; int index = 0; index = new Scanner(System.in); System.out.print("Enter ranking: "); ranking = stdIn.nextLine(); try { = = } try { Integer.parseInt(ranking); System.out.println("Rank "1 } catch (Number Format Exception e) { + index); System.out.println("Entered value must be an integer."); System.out.println(players[index 1]); } catch (IndexOutOfBounds Exception e) { System.out.println("Entry must be between 1 and + players.length); 11
Step by Step Solution
3.26 Rating (161 Votes )
There are 3 Steps involved in it
If the user enters first in response to the prompt in the provided Java program the following wil... View full answer
Get step-by-step solutions from verified subject matter experts
