For the program in Exercise 1, what is the output if the user enters first in response
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 below, what is the output if the user enters 3 in response to the prompt?
Transcribed Image Text:
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
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 100% (1 review)
If the user enters first in response to the prompt in the provided Java program the following wil...View the full answer
Answered By
Muhammad Umair
I have done job as Embedded System Engineer for just four months but after it i have decided to open my own lab and to work on projects that i can launch my own product in market. I work on different softwares like Proteus, Mikroc to program Embedded Systems. My basic work is on Embedded Systems. I have skills in Autocad, Proteus, C++, C programming and i love to share these skills to other to enhance my knowledge too.
3.50+
1+ Reviews
10+ Question Solved
Related Book For
Introduction To Programming With Java A Problem Solving Approach
ISBN: 9781260575248
3rd International Edition
Authors: John Dean
Question Posted:
Students also viewed these Computer science questions
-
9.1 Exercise (JDK Source Code): Extract the source code of the class Math from the JDK source code ("$JAVA_HOME" "src.zip" "Math.java" under folder "java.lang"). Study how constants such as E and...
-
In this assignment, you are writing a program that converts common texting abbreviations to English words to allow people like yours truly can understand. For the assignment, you are provided with a...
-
THIRD AVENUE SOFTWARE HEALTH-CARE APP PROJECT This case is new for the ninth edition of Information Technology Project Management . The case provides an opportunity to apply agile and Scrum...
-
An investor utilizes a bull call spread by purchasing a call option for a premium of $10. The call option comes with a strike price of $50 and expires in July 2020. At the same time, the investor...
-
Give an example where the read one, write all available approach leads to an erroneous state.
-
The lives of a certain automobile seal have the Weibull distribution with failure rate Z(t) = 1/t. Find the probability that such a seal is still intact after 4 years.
-
Two serious environmental problems have received considerable attention over the past three decades: (a) The serious depletion of ozone in the Earth's stratosphere, especially over the North and...
-
Horace Culpepper, CPA, was retained by Pulsar Cable to prepare financial statements for April 2020. Horace accumulated all the ledger balances per Pulsars records and found the following. Horace...
-
Given the following table, assess Mercy Hospital against the benchmarks for urban teaching hospitals, and so on. Explain Mercy Hospital's strengths and weaknesses in occupancy, payer mix, service...
-
Explain what the following program does for different possible user inputs. import java.util.Scanner; import java.util. InputMismatch Exception; public class Guess { public static void main(String[]...
-
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...
-
Consider the gain plot in Figure P12-53 . (a) Find a transfer function corresponding to the straight-line gain plot. Note that the magnitude of the actual frequency response must be exactly 5 at the...
-
Describe classes of embedded systems for which protection should definitely be provided! Describe classes of systems, for which we would possibly not need protection!
-
Find processors for which memory protection units are available! How are memory protection units different from the more frequently used memory management units (MMUs)? You may search in the Internet...
-
How is the use of the system stack optimized in ERIKA?
-
Which resource access protocols prevent deadlocks caused by exclusive access to resources?
-
Which problems have to be solved if Linux is used as an operating system for an embedded system?
-
What is meant by the characteristic of module coupling? What is its role in structure chart quality?
-
Following is the current balance sheet for a local partnership of doctors: The following questions represent independent situations: a. E is going to invest enough money in this partnership to...
-
When exactly 1 mole of methane is mixed with exactly 1 mole of chlorine and light is shone on the mixture, a chlorination reaction occurs. The products are found to contain substantial amounts of...
-
Using the parallel-axis theorem, determine the product of inertia of the area shown with respect to the centroidal x and y axes. -3 in. 15 in 6 in. 3 in. 9 in
-
Use Newton's method for three steps to solve the following equations. Find and sketch the tangent line for the first step, then find the Newton's method discrete-time dynamical system to check your...
-
Cash Accounts receivable Equipment, net Land Total assets Current Year Prior Year $ 10,400 $ 13,400 60,500 25,800 57,000 50,400 98,000 72,500 $ 225,900 $ 162,100 Compute the annual dollar changes and...
-
Find two job ads for positions in Stockton California you are either qualified for now or will be upon completion of your paralegal education program. For each job, write resume two ways, trying...
-
The following three identical units of Item P401C are purchased during April: Item Beta Units Cost Apr. 2 Purchase 1 $164 Apr. 15 Apr. 20 Total Average cost per unit ($504 3 units) Purchase 1 168...
Study smarter with the SolutionInn App