Buatlah program menghitung dan
menampilkan pola 
1                                              =
1
1 + 2                                        =
3
1 + 2 + 3                                 =
6
1 + 2 + 3 + 4                           = 10
....
P
E N Y E L E S A I N : 
package Soal7;
import java.util.*;
public class Main {
   
public static void main(String[] args) {
       
System.out.println("Program Menghitung dan Menampilkan Bilangan
sebanyak n");
       
System.out.println("______________________________________________________");
       
int n;
       
int i;
       
int j;
        
int hasil=0;
       
Scanner scan = new Scanner (System.in);
       
System.out.print ("Banyak Bilangan = ");
       
n = scan.nextInt();
       
for(i=1;i<=n;i++)
       
{
           
if(i==1)
           
{
                for(j=1;j<=i;j++)
                {
                System.out.print(+j);
                }
                System.out.print(" =
1");
                System.out.println();
           
}
           
else
                if(i>1)
           
{
            
for(j=1;j<=i;j++)
                {
                System.out.print(j);
                if(j<i)
                   
System.out.print("+");
                hasil=hasil+j;
                }
                System.out.print(" =
"+hasil);
                hasil=0;
                System.out.println();
                }
       
}
    }
}
H A S I L : 






Lucky Creek Casino & Resort - Mississippi
ReplyDeleteVisit the official Lucky Creek Casino 서울특별 출장샵 & Resort in Biloxi, MS for the 동두천 출장마사지 ultimate entertainment experience. Book your hotel stay with our Entertainment · Entertainment · Restaurants · 통영 출장안마 Lucky 안산 출장마사지 Creek Casino & Resort 구미 출장샵