bartleby

Concept explainers

bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 4.5, Problem 4.5.3CP

Explanation of Solution

Modified code:

//Import the package

importjava.util.*;

//Class definition

public class Smaple

{

public static void main(String[] args)

{

// Generate a two digit lottery string value

String lottery= "" + (int)(Math.random() * 100);

//declare the scanner variable

Scanner input= new Scanner(System.in);

// Prompt the user to enter the guess

System.out. print ( "Enter your lottery pick (two digits) : ") ;

//read the input

String guess = input.nextLine();

//fetch the digits from lottery variable

char lotteryDigit1 = lottery.charAt(0);

char lotteryDigit2 = lottery.charAt(1);

//fetch the digits from guess variable

char guessDigit1=guess.charAt(0);

char guessDigit2 = guess.charAt( 1);

//display the lottery value

System.out.println("The lottery number is " + lottery) ;

// analyze the guess

if (guess.equals(lottery))

{

//display the corresponding result

System...

Blurred answer
Students have asked these similar questions
Write in verilog coding language
Q4. Consider the following two design alternatives. Walmart Walmart Store locartion 1 * capacity - Associate Name 1 id position Design Alternative "A" Store locartion 1 capacity Associate Name 1 * id position Design Alternative "B" a) Explain the semantic differences between the two designs, if any. b) Explain the differences in how each design alternative may be implemented in Java. c) which design alternative may require more storage requirement in your opinion, and why?
Design a schematic for a compartmental model that includes compartments, flows, and parameters with their respective units, using Figure 1 as a guide. For each flow, determine whether it is best represented by a first-order transfer, a Michaelis-Menten saturable process, or a different method.

Chapter 4 Solutions

MyLab Programming with Pearson eText -- Access Card -- for Introduction to Java Programming and Data Structures, Comprehensive Version

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Control Structure in Data Structure - Data Structures - Computer Science Class 12; Author: Ekeeda;https://www.youtube.com/watch?v=9FTw2pXLhv4;License: Standard YouTube License, CC-BY