package maxmin;
import javax.swing.JOptionPane;
public class MaxMin
{
public static void main(String[] args)
{
final int Tnum = 5;
int num[] = new int[Tnum];
for(int i=0; i<num.length; i++)
{
String numstring = JOptionPane.showInputDialog(null,"Please enter number: ","User Input",
JOptionPane.QUESTION_MESSAGE);
num[i] = Integer.parseInt(numstring);
}
int max = num[0];
for(int i=0; i<num.length; i++)
{
if(max<num[i]);
max = num[i];
}
int min = num[0];
for(int i=0; i<num.length; i++)
{
if (min>num[i]);
min = num[i];
}
String MaxMin = "The array are : ";
for(int i=0; i<num.length; i++)
{
MaxMin = MaxMin + num[i] + " ";
}
MaxMin = MaxMin + "\nThe largest number is "+max;
MaxMin = MaxMin + "\nThe smallest number is "+min;
JOptionPane.showMessageDialog(null,MaxMin,"Number",
JOptionPane.INFORMATION_MESSAGE);
}
}
rezal 0 Newbie Poster
rezal 0 Newbie Poster
NormR1 563 Posting Sage Team Colleague
rezal 0 Newbie Poster
rezal 0 Newbie Poster
NormR1 563 Posting Sage Team Colleague
rezal 0 Newbie Poster
NormR1 563 Posting Sage Team Colleague
rezal 0 Newbie Poster
NormR1 563 Posting Sage Team Colleague
rezal 0 Newbie Poster
NormR1 563 Posting Sage Team Colleague
rezal 0 Newbie Poster
NormR1 563 Posting Sage Team Colleague
scudzilla 32 Junior Poster
rezal 0 Newbie Poster
NormR1 563 Posting Sage Team Colleague
rezal 0 Newbie Poster
NormR1 563 Posting Sage Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.