Using Math.max and/or Math.min, write a class MaxOrMin, and make sure touse Math.max and Math.min which does the following:a. Create a Scannerb. Declare two variables, number1 and number 2c. Ask the user to enter 2 numbersd. Using the information above, print messages displaying the highest and lowest values ora message if the numbers are equal. The messages should look like the sample outputbelowTip• Use if-else statementSubmission• Copy and paste your code• Screen shot the console with user input of three examplesSample RunEnter a number 5Enter a number 9The lowest value is 5The highest value is 9Enter a number 24Enter a number 11The lowest value is 11The highest value is 24Enter a number 12Enter a number 1212 and 12 are equal

Question
Asked Feb 26, 2019

Using Math.max and/or Math.min, write a class MaxOrMin, and make sure to
use Math.max and Math.min which does the following:

a. Create a Scanner
b. Declare two variables, number1 and number 2
c. Ask the user to enter 2 numbers
d. Using the information above, print messages displaying the highest and lowest values or
a message if the numbers are equal. The messages should look like the sample output
below

Tip
• Use if-else statement

Submission
• Copy and paste your code
• Screen shot the console with user input of three examples

Sample Run


Enter a number 5
Enter a number 9
The lowest value is 5
The highest value is 9

Enter a number 24
Enter a number 11
The lowest value is 11
The highest value is 24

Enter a number 12
Enter a number 12
12 and 12 are equal

check_circleExpert Solution
Step 1

Java code

import java.util.Scanner;
 
public class MaxOrMin {
public static void main(String[] args){
Scanner s=new Scanner(System.in);
int number1,number2;
System.out.println("Enter a number: ");
number1=s.nextInt();
System.out.println("Enter a number: ");
number2=s.nextInt();
if(Math.min(number1, number2)==Math.max(number1, number2)){
System.out.println(number1+" and "+number2+" ...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour*

See Solution
*Response times may vary by subject and question
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: Consider the following two assertions. Assume x is a specific but unknown real number.a. x < 2 o...

A: Let us name the statements as following:For expression (a)A: x < 2B: Not(1 < x < 3)so the e...

question_answer

Q: need help with understanding how to do the SQL code for the following question:  These are the heade...

A: As the table name is not shown in the picture, we are assuming the table name as Product. There are ...

question_answer

Q: // java // book is starting out with java //chapter 12  (5)Theater RevenueA movie theater only keeps...

A: Program plan:Import required packages.Define a class named “TheatreGUI”.Declare the required variabl...

question_answer

Q: create a python program that will ask users to input four different manufacturers of cars(e.g Ford, ...

A: Create a class Car and define _init_ () function which will initialize the value of variables manufa...

question_answer

Q: A pet shop wants to give a discount to its clients if they buy one or more pets and at least four ot...

A: The program has two main parts – the part which receives the input and the part which validates the ...

question_answer

Q: Write a class, AgeMessages , which does the following:a. Ask the user to enter age using a Scannerb....

A: The given below is the code to enter the age through user and print the message according to age. To...

question_answer

Q: Hi,please I need to use Python for the following: Use for loop to do the following: 1) print the num...

A: Program instructions:Use range() in for loop to print the numbers.Function range() has here argument...

question_answer

Q: Prove that the following languages are not regular: (b) L = {anblak : k ≠ n + l}.

A: First, assume the given language is regular.Then apply pumping lemma to prove the statement is not r...

question_answer

Q: Create a recursive store function called add_numbers to calculate the total of all consecutive posit...

A: As there is no specific programming language mentioned, so we are creating this program in C program...