here...a is an array....the data type is String.... This pgm takes values as command line... the first value is assignd to both min and max variables.... now, in a loop...till the end of the array...check each values against the max and min variables....then assign accordding to the comparison... we have to convert this array values into integer.
August 11, 2008 at 2:08 PM
Hi friend,
Import the java input output packages
import java.io.*;
public class MaxMinFun { public static void main(String[] args) throws IOException {
// Max Number to be inputted
System.out.println("Enter Number to be input: "); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String str = in.readLine();
// Enter the Number and store it in array;
int arlen = Integer.parseInt(str.toString()); int[] arr = new int[arlen]; for(int i=0;i<arlen;i++) { str = in.readLine(); arr[i] = Integer.parseInt(str.toString()); }
//code to calculate the maximum number :
int arrayMax[]= arr; int max = arrayMax[0]; for (int i=0; i<arrayMax.length; i++) { if(max<arrayMax[i]) { max = arrayMax[i]; } } System.out.println("max = " + max);
//code to calculate the minimum number :
int arrayMin[]= arr; int min=arrayMin[0]; for (int i=1; i<arrayMin.length; i++) { if(min>arrayMin[i]) { min = arrayMin[i]; } } System.out.println("min = " + min);
} }
Thanks
August 11, 2008 at 2:08 PM
is it the answer u r looking for.... Then if u got a better one, plz inform me also... thanks and reg.. prashu.. prashobvee@gmail.com
Related Pages:
how to calculate max and min in the loop - Java Beginners how to calculatemax and min in the loop thanks coz giving me... and min value in the loop. the input is from the user. could u teach me. thanks... main(String a[]) throws IOException
{
int max,min;
max=Integer.parseInt
how to calculate max and min - RUP how to calculatemax and min hye!i'm a new for the java and i want to ask a question . Could anyone help me to teach how to calculate the maximum... function max and min in java.
public class MathMaxMin {
public static
Max() Max() How to find maximum values A101,A107,A108 from a table in sql
Max() Max() How to find maximum values A101,A107,A108 from a table in sql
Mysql Min Max
Mysql MinMax
Mysql MinMax is useful to find the minimum and maximum records from a table.
Understand with Example
The Tutorial illustrate an example from Mysql MinMax
Min Value Min Value How to access min value of column from database table... min(id) from QuestionModel result_info";
Query query = session.createQuery(selectQuery);
System.out.println("Min Value : " +query.list().get(0
Find max and min value from Arraylist
Find max and min value from Arraylist
In this tutorial, you will learn how... max() and min() respectively. Here
is an example that consists of ArrayList of integers and using the max and min
methods of Collections class, we have find
Hibernate Min() Function (Aggregate Functions)
(...), min(...), max(...) , count(*), count(...), count(distinct ...),
count(all...
Hibernate Min() Function (Aggregate Functions)
In this section, we will show you, how to use
hibernate criteria Max Min Average Result Example
hibernate criteria MaxMin Average Result Example
In this Example, We... the Projections class max, min ,avg methods.
Here is the simple Example code files...("Max Salary is : ");
System.out.print(row[i]);
System.out.printf("\n
Calculate factorial of a number. Calculate factorial of a number. How to calculate factorial of a given number?
import java.io.BufferedReader;
import java.io.IOException... Integer.parseInt().
For loop from 1 to num-1 calculating the factorial value of num
Calculate sum and Average in java Calculate sum and Average in java How to calculate sum and average in java program?
Example:-
import java.io.BufferedReader;
import... the for loop, we have calculated the sum of all numbers. And after dividing
for loop
for loop how to performs the for loop when 2 inputs given like displays the triangle shape and how to take initial values or declaration values plz explain in detailed ex.
1
12
123
1234
Hibernate Max() Function (Aggregate Functions)
(...),
sum(...), min(...), max(...) , count(*), count(...), count(distinct...
Hibernate Max() Function (Aggregate Functions)
In this section, we will show you, how
Hibernate criteria query using Min().
Hibernate criteria query using Min(). How to find minimum value in Hibernate criteria query using Projection?
You can find out minimum...);
}
}
}
Output:
Hibernate: select min(this_.salary) as y0
Hibernate min() Function
will demonstrate you how to embed the HQL
min() function within your code...Hibernate min() Function
This section contains an example of the HQL min() function.
min() function in HQL returns the smallest value from the
selected
How to calculate attending hours? How to calculate attending hours? I need to calculate attending hours of a employee in a day in my project to make their monthly salary . By using work starting time and ending time. How should I do it using Date class? Or any
httpd.conf max connections
httpd.conf max connections Hi,
How to increase the MaxClients value in the apache httpd.conf file? Which is the entry in httpd.conf for max connections?
Thanks
Hi,
You can add following configuration in httpd.conf
how to calculate EMI of the loan how to calculate EMI of the loan
package carloanapp;
import java.io.FileWriter;
import java.io.IOException;
public class CarLoan {
Customer gObjCustomer = null;
double gDbRequestedLoanAmount = 0;
double
how to calculate the price on the option box how to calculate the price on the option box How i calculate the value when i using a option box with 2 option..first option i used for product name... to calculate this value
MySQL Aggregate Function
', 'MIN', 'MAX', and
'SUM') in the MySQL Query. The group (aggregate) functions...;
SELECT designation, MIN(salary)
, MAX(salary) FROM employee GROUP...;
This example illustrates how use the aggregate function
How to write a loop and a while loop How to write a loop and a while loop How do I write a 1 loop and a 1 while loop for the example code:
public boolean
isTheFirstOneBigger (int num1, int num2)
{
if (num1 > num2)
{
return true
how to i convert this case to loop...please help..... how to i convert this case to loop...please help..... import...");
System.out.println();
int Max = console.nextInt();
for (int i = 0; i < Max; i++) {
System.out.println
how to i convert this case to loop...please help..... how to i convert this case to loop...please help..... import...");
System.out.println();
int Max = console.nextInt();
for (int i = 0; i < Max; i++) {
System.out.println
how to i convert this case to loop...please help..... how to i convert this case to loop...please help..... import...");
System.out.println();
int Max = console.nextInt();
for (int i = 0; i < Max; i++) {
System.out.println
how to i convert this case to loop...please help..... how to i convert this case to loop...please help..... import...");
System.out.println();
int Max = console.nextInt();
for (int i = 0; i < Max; i++) {
System.out.println
how to i convert this case to loop...please help..... how to i convert this case to loop...please help..... import...");
System.out.println();
int Max = console.nextInt();
for (int i = 0; i < Max; i++) {
System.out.println
how to i convert this case to loop...please help..... how to i convert this case to loop...please help..... import...");
System.out.println();
int Max = console.nextInt();
for (int i = 0; i < Max; i++) {
System.out.println
how to i convert this case to loop...please help..... how to i convert this case to loop...please help..... import...");
System.out.println();
int Max = console.nextInt();
for (int i = 0; i < Max; i++) {
System.out.println
how to i convert this case to loop...please help..... how to i convert this case to loop...please help..... import...");
System.out.println();
int Max = console.nextInt();
for (int i = 0; i < Max; i++) {
System.out.println
how to i convert this case to loop...please help..... how to i convert this case to loop...please help..... import...");
System.out.println();
int Max = console.nextInt();
for (int i = 0; i < Max; i++) {
System.out.println
how to i convert this case to loop...please help..... how to i convert this case to loop...please help..... import...");
System.out.println();
int Max = console.nextInt();
for (int i = 0; i < Max; i++) {
System.out.println
How to calculate area of rectangle How to Calculate Area of Rectangle
In
this section we will learn how to calculate area... explain the static method how to
display the rectangle values. First of all we have
JDBC Select Max Example
JDBC Select Max Example
In this tutorial we will learn how use MAX... values that pass in
Max function i.e "SELECT MAX... query "SELECT MAX(user_id) FROM user" fetch the
maximum
For..in loop
For..in loop
In this tutorial we will study for..in loop which is similar to for each loop
of C#, Java and other popular languages, in this example
Hibernate max() Function
Hibernate max() Function
In this tutorial you will learn about how to use HQL max() function.
max() function in HQL returns the largest value from... below will demonstrate you how to embed the HQL
max() function within your code
JPA Max Function
JPA Max Function
In this section, you will learn how to develop a jpa
max function. JPA max function retrieves data from the database table field
which