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...
-
Nadia Shalom has the following transactions during the year: Sale of office equipment on March 15 that cost $19,000 when purchased on July 1, 2014. Nadia has claimed $3,000 in depreciation and sells...
-
The Tuckers owned an RV that they insured through American Family. On August 26, 2012, their RV was struck by lightning and damaged. The Tuckers reported the damage to American Family. In March 2013,...
-
The financial statements of Starbucks Corporation are presented in Exhibits 1.261.28. The income tax note to those financial statements reveals the information regarding income taxes shown in Exhibit...
-
If the input is 3210, what is output? Start x = Get next input TRUE x>0 Put 2 x to output FALSE Put to output End
-
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...
-
Provide a real-life example for each of the following different types of product liability: (a) negligence, (b) warranty, (c) strict liability, and (d) misrepresentation. When possible, report both...
-
On November 1, 2022, Big Grove Company collected $9.8 million cash from customers for products that would be delivered in January 2023. Based on the information provided, please answer the following...
-
Tony took out a $1,000,000 life insurance policy on his life 10 years ago. Last year, when the policy's interpolated terminal reserve was worth $400,000, Tony gave the policy to his son, Chuck. Tony...
-
Laila started her own business selling pet toys. She operates as a sole proprietorship earning 90,000 her first year. Laila's marginal tax rate is 22%. What is Laila's individual income tax liability?
-
In the construction industry, Kyle Engineering Inc. has secured a contract to build a state-of-the-art bridge at a contracted price of $18,000,000. The company follows the percentage-of-completion...
-
A corporation repurchased 8,000 of its own common shares, paying $8 per share. The shares were originally sold for an average of $5 per share. Assuming this is the first share repurchase undertaken...
-
Assume you are the CFO of a firm that manufactures electronics. Your firm is about to launch an extremely innovative new product. The product planning team has estimated life cycle sales of the...
-
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
-
For the beam shown below, plot the shear force and bending moment diagrams using the graphical method as we did in class. Track calculations on the side. Clearly label all maximums and minimums and...
-
8.8. a. In future chapters we will find it very useful to resolve a vector graphically. Explain what this means in a sentence. b. Resolve the vector below (i.e., draw the two vector components Ax and...
-
12.13. A toy car travels clockwise in a semi-circular path of radius r = 3.0m at a constant speed of |||| 4.8 m/s. -3 = A t = Os 82 B a. Since the car always moves with constant speed, then what is...
Study smarter with the SolutionInn App