public class DO{
public static void main(String [] args){
int n=0;
int m=0;
System.out.print("Deret :");
do {
n++;
m=m+n;
System.out.print(" "+n);
}
while(n<10);
System.out.println();
System.out.print("Jumlah : "+m);
}
}
Simpan file dengan nama DO.
public class DO2{
public static void main(String [] args){
int n=10;
int m=10;
System.out.print("Deret :");
do {
System.out.print(" "+n);
n--;
m=m-n;
}
while(n>0);
System.out.println();
System.out.print("Jumlah : "+m);
}
}
Simpan file dengan nama DO2.
No comments:
Post a Comment