Kodingan Sederhana mencari Nilai Rata - rata pada Java
Kodingan :
import javax.swing.JOptionPane;
public class Nilai{
public static void main( String[] args ){
String a= "";
String b= "";
String c= "";
a= JOptionPane.showInputDialog("Input Nilai Pertama");
int n1= Integer.valueOf(a).intValue();
b= JOptionPane.showInputDialog("Input Nilai Kedua");
int n2= Integer.valueOf(b).intValue();
c= JOptionPane.showInputDialog("Input Nilai Ketiga");
int n3= Integer.valueOf(c).intValue();
int rata=(n1+n2+n3)/3;
String hasil = "";
hasil += "Nilai Pertama :" + n1 + "\n";
hasil += "Nilai Kedua :" + n2 + "\n";
hasil += "Nilai Ketiga :" + n3 + "\n";
hasil += "Rata-Rata nilai :" + rata + "\n";
if (rata>=60){
hasil +="Good :)"+"\n";
}
else{
hasil +=":("+"\n";
}
JOptionPane.showMessageDialog(null, hasil);
}
}
Output :
import javax.swing.JOptionPane;
public class Nilai{
public static void main( String[] args ){
String a= "";
String b= "";
String c= "";
a= JOptionPane.showInputDialog("Input Nilai Pertama");
int n1= Integer.valueOf(a).intValue();
b= JOptionPane.showInputDialog("Input Nilai Kedua");
int n2= Integer.valueOf(b).intValue();
c= JOptionPane.showInputDialog("Input Nilai Ketiga");
int n3= Integer.valueOf(c).intValue();
int rata=(n1+n2+n3)/3;
String hasil = "";
hasil += "Nilai Pertama :" + n1 + "\n";
hasil += "Nilai Kedua :" + n2 + "\n";
hasil += "Nilai Ketiga :" + n3 + "\n";
hasil += "Rata-Rata nilai :" + rata + "\n";
if (rata>=60){
hasil +="Good :)"+"\n";
}
else{
hasil +=":("+"\n";
}
JOptionPane.showMessageDialog(null, hasil);
}
}
Output :
Kodingan Sederhana mencari Nilai Rata - rata pada Java
Reviewed by Lukems
on
09.33
Rating: 5