Ads

(adsbygoogle = window.adsbygoogle || []).push({});

Ads

(adsbygoogle = window.adsbygoogle || []).push({});

View Answers

August 11, 2008 at 1:49 PM

import java.io.*;

public class max_min1

{

public static void main(String a[]) throws IOException

{

int max,min;

max=Integer.parseInt(a[0]);

min=Integer.parseInt(a[0]);

for(int i=0;i<a.length;i++)

{

if(Integer.parseInt(a[i])<min)

min=Integer.parseInt(a[i]);

if(Integer.parseInt(a[i])>max)

max=Integer.parseInt(a[i]);

}

System.out.println("MAX: "+max+" MIN: "+min);

}

}

public class max_min1

{

public static void main(String a[]) throws IOException

{

int max,min;

max=Integer.parseInt(a[0]);

min=Integer.parseInt(a[0]);

for(int i=0;i<a.length;i++)

{

if(Integer.parseInt(a[i])<min)

min=Integer.parseInt(a[i]);

if(Integer.parseInt(a[i])>max)

max=Integer.parseInt(a[i]);

}

System.out.println("MAX: "+max+" MIN: "+min);

}

}

August 11, 2008 at 1:53 PM

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.

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

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..

[email protected]

Then if u got a better one, plz inform me also...

thanks and reg..

prashu..

[email protected]

Ads

(adsbygoogle = window.adsbygoogle || []).push({});
// to set WMD's options programatically, define a "wmd_options" object with whatever settings
// you want to override. Here are the defaults:
wmd_options = {
// format sent to the server. Use "Markdown" to return the markdown source.
///output: "HTML",
output: "Markdown",
// line wrapping length for lists, blockquotes, etc.
lineLength: 40,
// toolbar buttons. Undo and redo get appended automatically.
buttons: "bold italic | link blockquote code image | ol ul heading hr",
// option to automatically add WMD to the first textarea found. See apiExample.html for usage.
autostart: true
};

Related Tutorials/Questions & Answers: