import java.io.*;
import java.text.DecimalFormat;
public class soal1 {
public static void main(String args[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(2);
soal1 s1 = new soal1();
System.out.println("+++ Program sederhana penghitung nilai rata-rata +++");
System.out.print(" Masukkan bilangan pertama : ");
s1.setN1(Double.parseDouble(br.readLine()));
System.out.print(" Masukkan bilangan kedua : ");
s1.setN2(Double.parseDouble(br.readLine()));
System.out.print(" Masukkan bilangan ketiga : ");
s1.setN3(Double.parseDouble(br.readLine()));
System.out.println(" ");
System.out.println(" "+s1.isStatus());
System.out.println(" ");
System.out.println("+-------------------------------------+");
System.out.println(" Nilai Rata-Rata : "+df.format(s1.NR()));
System.out.println("+-------------------------------------+");
}
private double N1;
private double N2;
private double N3;
private double NR;
//Bilangan pertama
public void setN1(double N1){
this.N1 = N1;
}
public double getN1(){
return N1;
}
//Bilangan kedua
public void setN2(double N2){
this.N2 = N2;
}
public double getN2(){
return N2;
}
//Bilangan ketiga
public void setN3(double N3){
this.N3 = N3;
}
public double getN3(){
return N3;
}
//Nilai Rata2
public double NR() {
NR=((Double.valueOf(N1)+Double.valueOf(N2)+Double.valueOf(N3))/3);
return NR;
}
//status
public String isStatus(){
String isStatus = (NR >= 60) ? " :-) " : " :-( ";
return isStatus;
}
}
Senin, 17 Maret 2014
java
kasih gamabar outputnya gan
BalasHapuskunjungi back
http://chameleoncute.blogspot.co.id/2017/10/membuat-kalkulator-menggunakan-java-gui.html