How To Find Minimum And Maximum Sum Values In Java

I have seen many asking this question like how to get minimum and maximum in java to sum both of them. This process is simple to find Mini-max Sum Discussions but it required small practice to serve the purpose. Java – Math.max and Math.min outputting the highest and lowest values can get output by using the several ways. It depends upon the programmers that for what purpose him/her making the program to get output. Must check Count repeated characters in a string using java.

Mini-Max Sum Discussions

To get the output minimum and maximum sum values here I have applied some sort and simple methods, which all process hugging to your book.  While making you understand these “minimum and maximum values in a Java array” I have created some unnecessary variable to make you better understand. Must check prime number in java and factorial program in java.

Mini-max Sum Discussions

In this Mini-max Sum Discussions topic, it covers several topics, Such as…….

  • Scanner class.
  • How to make a one-dimensional array.
  • How to apply here Bubble short methods.
  • Some initialization.

So first let’s see the whole program of Mini-Max Sum.

1| import java.util.*;
2| public class amaxlowsum
3| {
4| public static void main(String[] args)
5| {
6| Scanner input= new Scanner(;
7| System.out.print(“Enter number here ::”);
8| System.out.println();
9| int arr[]= new int[5];
10| for (int i=0; i<arr.length; i++)
11| {
12| arr[i]=input.nextInt();
13| }
14| int temp=0;
15| int count=0;
16| for (int i=0; i<arr.length; i++)
17| {
18| for (int j=0; j<arr.length-1; j++)
19| {
20| if (arr[j]>arr[j+1])
21| {
22| temp=arr[j+1];
23| arr[j+1]=arr[j];
24| arr[j]=temp;
25| }
26| }
27| count++;
28| }
29| System.out.println(“Sorting number :: “);
30| for (int k=0; k<arr.length; k++)
31| {
32| System.out.print(arr[k]+ ”  “);
33| }
34| int low=0;
35| int max=0;
36| for (int l=0; l<arr.length; l++)
37| {
38| low=arr[0];
39| max=arr[4];
40| }
41| System.out.println();
42| System.out.println(“Lower number :: “+low);
43| System.out.println(“Maximum number :: “+max);
44| int sum=max+low;
45| System.out.print(“This is sum of maxlow :: “+sum);
46| }
47| }

Mini-Max Sum Output

In below image check the output for mini-max sum. Mini-Max Sum Output and also, I have uploaded the text file. So download this and check.

Mini-Max Sum Output                Min & Max Sum

find minimum and maximum values in a Java array

Must check suggested java program.

find minimum and maximum values in a Java array Conclusion

Above I have given you code to find out ‘java – Math.max and Math.min outputting highest and lowest values’. After reading this code you can manage to amend this as per the purpose. By amending above code user can use it for several purposes.

Just by interacting with this code user can do the sum of any number as per the requirement. And also can print it for ascending and descending order. Such as the series of the form top to the bottom maximum number and also from lower to top order.

Make sure first go throw with this code because this code helps users to develop android and windows applications and then use it for Mini-Max Sum. While using the code or in understanding the above the code if you have any dough so let me know below commenting box.

Speak Your Mind


error: Content is protected !! Protection Status