Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

TheExtremesclass represents the range ofIntegervalues. Fill in theExtremesmethods. In the constructor, setminandmaxto the minimum and maximum value ofInteger. UseInteger.MIN_VALUEandInteger.MAX_VALUE. Also fill in theminDiffandmaxDiffmethods to return

TheExtremesclass represents the range ofIntegervalues.

Fill in theExtremesmethods. In the constructor, setminandmaxto the minimum and maximum value ofInteger. UseInteger.MIN_VALUEandInteger.MAX_VALUE. Also fill in theminDiffandmaxDiffmethods to return the difference between the users guess and the actual max/min values ofInteger.

Main

Inmain, use the comments as a guide to ask the user to guess the maximum and minimum values. Compute the difference between the guess and the values, then print it out.

Be aware that if you choose a number too big or too small, it will cause an error since the number cannot be stored.

The results inmainshould look something like this:

Guess the maximum Integer value: 543214 You were off by 2146940433 Guess the minimum Integer value: 2145678321 You were off by 1805327 

2.9.8: Guess the number!

importjava.util.Scanner; importjava.lang.*; publicclassExtremeMain { publicstaticvoidmain(String[]args) { //CreateaScannerobject   //CreateanExtremesobject   //AsktheusertoguessthemaximumvalueofanInteger   //Computeanddisplaythedifference //betweenthemaxandtheguess   //AsktheusertoguesstheminimumvalueofanInteger   //Computeanddisplaythedifference //betweentheminandtheguess   } } 

 publicclassExtremes { Integermin; Integermax;  //Constructor publicExtremes() { //Setminandmaxvalues }  //Returnsthedifference //max-number publicIntegermaxDiff(Integernumber) {  } //Returnsthedifference //min-number publicIntegerminDiff(Integernumber) {  }  //ReturnsaStringrepresentation //intheform //[min,max] publicStringtoString() { return"["+min+","+max+"]"; } } 

Need help solving this problem

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Unity From Zero To Proficiency Beginner A Step By Step Guide To Coding Your First Game

Authors: Patrick Felicia

1st Edition

1091872023, 978-1091872028

More Books

Students also viewed these Programming questions

Question

Use resolution to answer the query in Example 3.3.4.

Answered: 1 week ago