Coding:
package Praktik1;
import javax.swing.JOptionPane;
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class JAVAkombinasiscript3input {
public static void main(String[] args){
//scanner
Scanner input = new Scanner (System.in);
System.out.println("First Number : ");
String fn = input.nextLine();
//Buffered Reader
BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));
String sn = "";
System.out.print("Second Number : ");
try {
sn = dataIn.readLine();
}
catch(IOException e) {
System.out.println("Error!");
}
//JOptionPane
String tn = JOptionPane.showInputDialog("Third Number : ");
int n1 = Integer.parseInt(fn);
int n2 = Integer.parseInt(sn);
int n3 = Integer.parseInt(tn);
int hasil = (n1*n2)/n3;
JOptionPane.showMessageDialog(null, "Jawaban dari ( " +fn +" x " +sn +" ) : " +tn +" = " +hasil,
"JAWABAN", JOptionPane.PLAIN_MESSAGE);
}
}
Screen Shoot:
Tekan Shift+f6
0 komentar:
Posting Komentar