About 2,020,000 results
Open links in new tab
  1. java - How do I get the max and min values from a set of …

    Here's a possible solution: public static void main(String [] args) { int min = Integer.MAX_VALUE; int max = Integer.MIN_VALUE; Scanner s = new Scanner(System.in); while (true) { System.out.print("Enter a Value: "); int val = s.nextInt(); if (val == 0) { break; if (val < min) { min = val; if (val > max) { max = val;

  2. java - getting max and min of five input from user - Stack Overflow

    Jun 11, 2018 · I want to calculate max and min of five inputs from the user, i managed to get max value but failed to get the min value instead i am getting 0 as my min value which was initialized from before in class Compare. How can i get the min value in the simplest possible way.

  3. How can I get the min and max value of the user input? (Java)

    //for your case if value is between 0 and 100 int min = 101; int max = 0; if(note>=1 && note<=100) { total=total+note; i++; //checking minimum value if(note < min) min = note; //checking maximum value if(note > max) max = note; }else { System.out.println("Enter integer between 1 …

  4. How to calculate Maximum and minimum in Java? Beginner …

    The purpose of this article is to teach you how to get input from a user in Java and how to use java.lang.Math class to perform some mathematical operation e.g. max, min or average. You can use the Scanner class, added in Java 1.5 to read user input from the console.

  5. Min and Max in a List in Java - GeeksforGeeks

    Jan 11, 2023 · Given an unsorted list of integers, find maximum and minimum values in it. Output : max = 20, min = 1. Input : list = [10, 400, 3, 2, 1, -1] Output : max = 400, min = -1. Sorting. This is least efficient approach but will get the work done.

  6. The goal of this homework is to continue practicing writing some simple java functions. You will do the following: 1.Implement the two methods shown below. 2.Implement a small program (main method) to accept user input, print results, etc. 3. FILESTODOWNLOAD: None 4. FILETOSUBMIT: MinMax.java 1.1 MIN AND MAX FUNCTIONS

  7. Integer.MAX_VALUE and Integer.MIN_VALUE in Java with …

    Jan 22, 2020 · Integer.MAX_VALUE is a constant in the Integer class of java.lang package that specifies that stores the maximum possible value for any integer variable in Java. The actual value of this is. Any integer variable cannot store any value beyond this limit. Upon doing so, the memory will overflow and the value will get negative.

    Missing:

    • User Inputs

    Must include:

  8. Java Math max() method with Examples - GeeksforGeeks

    Apr 16, 2018 · The Java.lang.math.min() function is an inbuilt function in java that returns the minimum of two numbers. The arguments are taken in int, double, float and long. If a negative and a positive number is passed as an argument then the negative result is generated.

    Missing:

    • User Inputs

    Must include:

  9. Finding the minimum and maximum values in a user inputed array (Java ...

    Apr 5, 2016 · if (numbers[count-1] < min) { min = numbers[count-1]; } condition inside the while loop. This will find the minimum in the same loop that reads the input. Of course, if you do that, you don't need to store the elements in an array at all, so you can further simplify the code.

  10. Java program to find maximum and minimum values of a list …

    Steps to find maximum and minimum values in a list : Get the total count of the numbers from the user. Using a loop, get the inputs of the numbers. Add these numbers to a list. Now, get the value of maximum and minimum of the range. We need to find the maximum and minimum of all numbers within this range.

Refresh