Java Code To Find The Maximum And Minimum All Numbers Without Arrays.
=============================================================try {
int a = 0, b = 0, c = 0, d=Integer.MAX_VALUE;
//d=Integer.MAX_VALUE because the d is set to its maximum value as being an integer
// and it is of the order 2^31-1
do {
a = Integer.parseInt(jOptionPane1.showInputDialog(null, "please enter the number"));
b = Math.max(a, b);
c = Math.min(a, d);
if (a != 0) {
d = c;
}
} while (a != 0);
lb1.setText("Maximum of the numbers is " +b);
lb2.setText("Minimum of the numbers is " + d);
} catch (Exception e) {
jOptionPane1.showMessageDialog(this, "Some thing went wrong");
}
GUI SAMPLES:
============ Press Find to Start:>>
The programe shows Input JOptionPane Until we Enter 0 >>
No comments:
Post a Comment