Sunday, October 9, 2011

How to summing the integers from 1 to 10

Summing the integers from 1 to 10 in Java ( menjumlahkan bilangan dari 1 sampai 10 dalam Java).

Analysis algorithms
* We need an integer whose value is changed from 1 to 10 and identified as i.
* Integer variables are needed to accommodate the number of all integers and identified as a Sum.


Desaign :
* For the first, we declarate Sum = 0;
* for i = 1 s/d 10, sum = sum + 1;
* print sum.


Coding :


public class task1 {
                    public static void main ( String [ ] args )  {
                    int i, sum=0;
                    for (i=1; i<11 ; i++)   {
                              sum = sum + 1;
                    }
                    System.out.println("Results = " + sum) ;
                    }
}

Ok, that is our first lesson. Summing the integers from 1 to 10 in Java have simple algorithms and coding. If you don't understand, please comment at this post so we can dicuss it together.
Guys jangan lupa comment kalau ada yang kurang dimengerti dalam postingan menjumlahkan bilangan dari 1 sampai 10 dalam Java.