import jeliot.io.*;
public class hitung {
public void input(){
System.out.println("tentukan nilai n:");
n=Input.readInt();
}
public void proses(){
jumlah=0;
total=0;
rumus=-1;
for(int j=1; j<=n; j++)
{
rumus=(rumus*(-1));
total=rumus/j;
jumlah+=total;
if(j==1)
System.out.println(+total);
if(j>1)
System.out.println(+total);
System.out.println("hasil penjumlahan deret = "+jumlah);
}
}
private int n;
private float rumus,jumlah,total;
public static void main() {
hitung h=new hitung();
h.input();
h.proses();
}
}
public class hitung {
public void input(){
System.out.println("tentukan nilai n:");
n=Input.readInt();
}
public void proses(){
jumlah=0;
total=0;
rumus=-1;
for(int j=1; j<=n; j++)
{
rumus=(rumus*(-1));
total=rumus/j;
jumlah+=total;
if(j==1)
System.out.println(+total);
if(j>1)
System.out.println(+total);
System.out.println("hasil penjumlahan deret = "+jumlah);
}
}
private int n;
private float rumus,jumlah,total;
public static void main() {
hitung h=new hitung();
h.input();
h.proses();
}
}
0 komentar:
Posting Komentar