Explain what the following program does for different possible user inputs. import java.util.Scanner; import java.util. InputMismatch Exception;
Question:
Explain what the following program does for different possible user inputs.
Transcribed Image Text:
import java.util.Scanner; import java.util. InputMismatch Exception; public class Guess { public static void main(String[] args) { Scanner stdIn = new Scanner (System.in); int guess, num (int) (Math.random() * 10); try { = System.out.println("Guess the winning digit or 'q' to quit"); while ((guess = stdIn.nextInt()) != num) {} System.out.println("Good Guess!"); } // end try catch (InputMismatchException e) { System.out.println("Sorry, but thanks for trying!"); } } // end main } // end Guess class
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 100% (QA)
The provided program is a simple number guessing game written in Java Heres what the program does stepbystep 1 Import Statements The program imports t...View the full answer
Answered By
Kumar Madhav Narayan
I have been helping students for the last 10 years i.e. when I was aged 15. Helping students keep me updated and I am considering becoming a teacher full time in the coming time.
I mainly deal with statistics and machine learning but I am equally happy to solve other topics of maths and economics.
0.00
0 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
-
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...
-
Your task is to create a game where the users can play with words and numbers. The game has three consecutive levels (Level 1, Level 2, and Level 3). Users can proceed to the next level after...
-
On April 19, 2019, the US Securities and Exchange Commission (SEC) published a settled administrative proceeding against Prosper Funding LLC (Prosper) for violating Section 17(a)(2) of the Securities...
-
Sandhill Company manufactures hockey pucks and soccer balls, For both products, materials are added at the beginning of the production process and conversion costs are incurred evenly. Sandhill uses...
-
If we apply a distributed version of the multiple-granularity protocol of Chapter to a distributed database, the site responsible for the root of the DAG may become a bottleneck. Suppose we modify...
-
A telemarketing company has a special letter opening machine that opens and removes the contents of an envelope. If the envelope is fed improperly into the machine, the contents of the envelope may...
-
Design teams are confronted with "multiobjective" decision making. Is it possible for objectives to lead to conflicting designs? Give an example(s).
-
A meta-analysis (Anderson & Bushman, 2001) reported that the average correlation between time spent playing violent video games (X) and engaging in aggressive behavior (Y) in a set of 21...
-
What are organizations doing to effectively manage diversity? What methods of managing a diverse work environment tend to work best?
-
Suppose you have a program with a method call youre unfamiliar with. Describe the best way to determine if that method might throw an unchecked exception. And if you find that the method call might...
-
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...
-
(a) Imagine you have a dollar bill. If you double it, you have two bills. If you double again, you have four bills. If you double again, you have eight bills, and so on. Given that a bill is 0.1mm...
-
In the context of memories, we are sometimes saying small is beautiful. What could be the reason for this?
-
Which of the following languages use a broadcast mechanism for updating variables: StateCharts, SDL, or Petri nets?
-
Some FPGAs support an implementation of all Boolean functions of six variables. How many such functions exist? We ignore that some functions differ only by a renaming of variables.
-
Why is it so important to optimize embedded systems? Compare different technologies for processing information in an embedded system with respect to their efficiency!
-
Which of the following languages use asynchronous message passing: StateCharts, SDL, VHDL, CSP, Petri nets, or MPI?
-
What are the five types of coupling? Give an example of good coupling and an example of bad coupling.
-
Michelles trust is subject to 3.8% surtax on the lesser of the trusts net investment income or the excess of the trusts adjusted gross income over the $12,400 threshold (the highest trust tax rate)....
-
Draw Lewis structures for the following compounds and ions, showing appropriate formal charges. (a) [CH3OH2]+ (b) NH4CI (c) (CH)4NCI (d) NaOCH3 (e) +CH3 (f) -CH3 (g) NaBH4 (h) NaBH3CN (i) (CH3)2O-BF3...
-
How do debt securities and equity securities differ?
-
Convert the given unit to the unit indicated. 6.5 km to millimeters
-
Locate three mission statements (not used in the text) for sport-related entities/organizations and copy and paste them to your answer document. Which one of the three do you feel is the most...
-
Presented below is information related to Sheridan Company for the month of January 2022. Ending inventory per Insurance expense $11,340 perpetual records $29,890 Rent expense 24,070 Ending inventory...
-
Design a plan for developing and implementing school practices with community members, families, and staff to create a more inclusive and culturally responsive school. Include professional...
Study smarter with the SolutionInn App