Class Blueprintnya :
public class Cetele {
String nama;
int alquran;
String puasa;
String tahajjud;
float sedekah;
Cetele(String nama,int alquran,String puasa, String tahajjud,float sedekah){
this.nama=nama;
this.alquran=alquran;
this.puasa=puasa;
this.tahajjud=tahajjud;
this.sedekah=sedekah;
}
public int nilBacaAlQuran(){
int nilquran=alquran*40;
return nilquran;
}
public int nilPuasa(){
int nilpuasa=0;
if (puasa.equals("Y")){
nilpuasa=35;
}
return nilpuasa;
}
public int nilTahajjud(){
int nilthjud=0;
if (tahajjud.equals("Y")){
nilthjud=30;
}
return nilthjud;
}
public void nilSedekah(){
float hasil=sedekah*10;
System.out.println("Ganjaran atas sedekah anda sebesar : Rp."+hasil);
}
public void tktKeislaman(){
int total=(nilBacaAlQuran()+nilPuasa())+nilTahajjud();
if (total>=120){
System.out.println("Status Keislaman : Sempurna");
}else if (total>=95){
System.out.println("Status Keislaman : Baik");
}else if (total<95) {
System.out.println("Status Keislaman : Dirtanyakan!");
}
}
public void cetakHasil(){
System.out.println("Nama : "+nama);
tktKeislaman();
nilSedekah();
}
}
String nama;
int alquran;
String puasa;
String tahajjud;
float sedekah;
Cetele(String nama,int alquran,String puasa, String tahajjud,float sedekah){
this.nama=nama;
this.alquran=alquran;
this.puasa=puasa;
this.tahajjud=tahajjud;
this.sedekah=sedekah;
}
public int nilBacaAlQuran(){
int nilquran=alquran*40;
return nilquran;
}
public int nilPuasa(){
int nilpuasa=0;
if (puasa.equals("Y")){
nilpuasa=35;
}
return nilpuasa;
}
public int nilTahajjud(){
int nilthjud=0;
if (tahajjud.equals("Y")){
nilthjud=30;
}
return nilthjud;
}
public void nilSedekah(){
float hasil=sedekah*10;
System.out.println("Ganjaran atas sedekah anda sebesar : Rp."+hasil);
}
public void tktKeislaman(){
int total=(nilBacaAlQuran()+nilPuasa())+nilTahajjud();
if (total>=120){
System.out.println("Status Keislaman : Sempurna");
}else if (total>=95){
System.out.println("Status Keislaman : Baik");
}else if (total<95) {
System.out.println("Status Keislaman : Dirtanyakan!");
}
}
public void cetakHasil(){
System.out.println("Nama : "+nama);
tktKeislaman();
nilSedekah();
}
}
Class Objectnya :
import javax.swing.JOptionPane;
public class DemoCetele {
public static void main(String[] args) {
int x=Integer.parseInt(JOptionPane.showInputDialog(null,"Untuk Berapa Orang?"));
int arr[]=new int [x];
for (int i=0;i<arr.length;i++){
String nama=JOptionPane.showInputDialog("Nama Orang ke-"+(i+1));
int hal=Integer.parseInt(JOptionPane.showInputDialog("Berapa halaman membaca Al-Quran?"));
String puasa=JOptionPane.showInputDialog("Puasa? (Y/N)");
String tahajud=JOptionPane.showInputDialog("Tahajjud? (Y/N)");
float sdkh=Float.parseFloat(JOptionPane.showInputDialog("Nominal Sedekah"));
Cetele insan=new Cetele(nama,hal,puasa,tahajud,sdkh);
insan.cetakHasil();
}
}
}
public class DemoCetele {
public static void main(String[] args) {
int x=Integer.parseInt(JOptionPane.showInputDialog(null,"Untuk Berapa Orang?"));
int arr[]=new int [x];
for (int i=0;i<arr.length;i++){
String nama=JOptionPane.showInputDialog("Nama Orang ke-"+(i+1));
int hal=Integer.parseInt(JOptionPane.showInputDialog("Berapa halaman membaca Al-Quran?"));
String puasa=JOptionPane.showInputDialog("Puasa? (Y/N)");
String tahajud=JOptionPane.showInputDialog("Tahajjud? (Y/N)");
float sdkh=Float.parseFloat(JOptionPane.showInputDialog("Nominal Sedekah"));
Cetele insan=new Cetele(nama,hal,puasa,tahajud,sdkh);
insan.cetakHasil();
}
}
}
Leony Li
By
Published: 2013-10-21T15:59:00-07:00
Aplikasi Java Perhitungan Nilai Ibadah
By
Published: 2013-10-21T15:59:00-07:00
Aplikasi Java Perhitungan Nilai Ibadah