import jeliot.io.*;
public class hitung {
public void masuk(){
System.out.print("nilai n : ");
n=Input.readInt();
}
public double proses(){
for(int i=1; i<=n; i++){
rumus=(rumus*(-1));
total=rumus/i;
jumlah+=total;
if(i==1) System.out.print("("+total+")");
if(i>1) System.out.print(" + ("+total+")");
}
return jumlah;
}
public void keluar(){
System.out.println("");
System.out.print("hasil penjumlahan baris = "+jumlah);
}
private int n;
private double jumlah=0;
private double total=0;
private double rumus=-1;
public static void main() {
hitung ini=new hitung();
ini.masuk();
ini.proses();
ini.keluar();
}
}
Minggu, 24 April 2011
program interjer
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar