4-9 Maximum
Post date: Feb 28, 2014 3:55:40 PM
/*
Write a program in java to read n numbers from the keyboard then find two numbers you entered biggest?
*/
package maximum;
import javax.swing.JOptionPane;// Needed for JOptionPane
public class Maximum
{
public static void main(String[] args)
{
int Count=Integer.parseInt(JOptionPane.showInputDialog("How many numbers will you enter?"));
int F_Largest=Integer.parseInt(JOptionPane.showInputDialog("Enter The Number1")),S_Largest=F_Largest,Store;
for (int i =1; i < Count; i++)
{
Store=Integer.parseInt(JOptionPane.showInputDialog("Enter The Number"+(i+1)));
if(Store > F_Largest)
{
S_Largest=F_Largest;
F_Largest=Store;
}
else
if(S_Largest<Store||F_Largest==S_Largest)
S_Largest=Store;
}
JOptionPane.showMessageDialog(null,"First Largest number="+F_Largest+"\nSecond Largest number="+S_Largest);
}
}