Nhap2SoNguyen
import javax.swing.JOptionPane;
public class Nhap2SoNguyen{
public static void main(String args[]){
String result1, result2;
int output1 = 0, output2 = 0;
result1 = JOptionPane.showInputDialog("Hay nhap so thu 1:");
for (int index = 0; index < result1.length(); index++){
char c = result1.charAt(index);
if (Character.isDigit(c))
output1 = output1 * 10 + Character.digit(c, 10);
}
result2 = JOptionPane.showInputDialog("Hay nhap so thu 2:");
for (int index = 0; index < result1.length(); index++){
char c = result2.charAt(index);
if (Character.isDigit(c))
output2 = output2 * 10 + Character.digit(c, 10);
}
JOptionPane.showMessageDialog(null,"Ban vua nhap vao so " + output1 + " va so " +output2);
System.exit(0);
}
}
Bạn đang đọc truyện trên: AzTruyen.Top