Full width home advertisement

Travel the world

Climb the mountains

Post Page Advertisement [Top]

Java

Penjumlahan Data Menggunakan Array

Berikut ini kode penjumlahan array pada Java yang menggunakan perulangan for :

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package array;
import java.util.Scanner;
/**
 *
 * @author user
 */
public class Array {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner a =new Scanner(System.in);
    int[] buku = new int[10];
    for(int i=0;i<10;i++){
    buku[i]=a.nextInt();
    }
       int total=0;
        for(int i=0;i<10;i++){
         total += buku[i];
        }
        System.out.println(total);
    }
   
}

No comments:

Post a Comment

Bottom Ad [Post Page]

| Designed by Colorlib