Hasil Output :
Code :
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import javax.swing.JOptionPane;
public class Input_dengan_3_cara_berbeda {
public static void main(String args[])
{
double N1, N2 = 0, N3, NR;
String n3;
Scanner nilai1 = new Scanner(System.in);
System.out.print("Masukan nilai pertama \t : ");
N1 = nilai1.nextDouble();
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try
{
System.out.print("Masukkan nilai kedua \t : ");
N2 = Integer.parseInt(in.readLine());
}
catch(Exception e)
{
System.out.println(e);
}
n3 = JOptionPane.showInputDialog("Masukkan nilai ketiga : ");
N3 = Integer.parseInt(n3);
//proses
NR = (N1 + N2 + N3) / 3;
JOptionPane.showMessageDialog(null, NR);
}
}
Code :
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import javax.swing.JOptionPane;
public class Input_dengan_3_cara_berbeda {
public static void main(String args[])
{
double N1, N2 = 0, N3, NR;
String n3;
Scanner nilai1 = new Scanner(System.in);
System.out.print("Masukan nilai pertama \t : ");
N1 = nilai1.nextDouble();
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try
{
System.out.print("Masukkan nilai kedua \t : ");
N2 = Integer.parseInt(in.readLine());
}
catch(Exception e)
{
System.out.println(e);
}
n3 = JOptionPane.showInputDialog("Masukkan nilai ketiga : ");
N3 = Integer.parseInt(n3);
//proses
NR = (N1 + N2 + N3) / 3;
JOptionPane.showMessageDialog(null, NR);
}
}
1 comments:
Makasih gan... Sangat membantu.,. :)
Keep move!!
Post a Comment