I want to share how to display Input Output Programme in Java SE. You can use this code but if you copy this code and
paste in your blog/website, please insert this link of article.
----------------
import javax.swing.JOptionPane;
public class ProgramIO{
public static void main(String[] args){
double jumlah,kurang, bagi,kali;
double bil1,bil2;
bil1=Double.parseDouble(JOptionPane.showInputDialog("Masukkan bilangan 1"));
bil2=Double.parseDouble(JOptionPane.showInputDialog("Masukkan bilangan 2"));
jumlah=bil1+bil2;
kurang =bil1-bil2;
bagi=bil1/bil2;
kali=bil1*bil2;
JOptionPane.showMessageDialog(null,"Hasil Penjumlah : + jumlah");
JOptionPane.showMessageDialog(null,"Hasil Pengurangan : + kurang");
JOptionPane.showMessageDialog(null,"Hasil Pembagian :" + bagi);
JOptionPane.showMessageDialog(null,"Hasil Perkalian :" + kali);
}
}
====
of if you use parseInt, this the code:
int bil1,bil2,jumlah,kurang,kali,bagi;
bil1=Integer.parseInt(JOptionPane.showInputDialog("Masukkan bilangan1"));
bil2=Integer.parseInt(JOptionPane.showInputDialog("Masukkan bilangan1"));
jumlah=bil1+bil2;
kurang=bil1-bil2;
kali=bil1*bil2;
bagi=bil1/bil2;
JOptionPane.showMessageDialog(null,"Hasil Penjumlah :" + jumlah);
JOptionPane.showMessageDialog(null,"Hasil Pengurangan :" + kurang);
JOptionPane.showMessageDialog(null,"Hasil Perkalian :" + kali);
JOptionPane.showMessageDialog(null,"Hasil Pembagian :" + bagi);
0 komentar:
Posting Komentar