90
Write a complete Java program that prompts the user to input two integer values and outputs the
largest and smallest numbers.
The program includes JOptionPane for both the input and output statements.
import javax.swing.JOptionPane;
/**
*
* @author layla
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int num1 ;
int num2 ;
int bignum = 0;
int smallnum = 0;
num1 = Integer.parseInt(JOptionPane.showInputDialog("Enter First Number"));
num2 = Integer.parseInt(JOptionPane.showInputDialog("Enter Second Number"));
if(num1 > num2 ){
bignum = num1;
}
else {
smallnum = num1;
}
if (num2 > num1){
bignum = num2 ;
}else {
smallnum = num2;
}
JOptionPane.showMessageDialog(null,bignum );
JOptionPane.showMessageDialog(null,smallnum);
}
}
How to create a user with sudo privileges in Kali Linux 2020
1 comment
[…] Java program that prompts the user to input two integer values and outputs the largest and smallest … […]