SHARE
TWEET

Untitled

a guest Nov 12th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2. public class Tugas8_1
  3. {
  4.     public static void main(String args[])
  5.     {
  6.         Scanner in = new Scanner(System.in);
  7.         int panjang;
  8.         int i = 0;
  9.         float jumlah = 0;
  10.         float rata;
  11.         System.out.print("Panjang data = ");
  12.         panjang = in.nextInt();
  13.         int[] data = new int[panjang];
  14.         while(i <= panjang - 1)
  15.         {
  16.             System.out.print("Data"+i+" = ");
  17.             data[i] = in.nextInt();
  18.             jumlah = jumlah + data[i];
  19.             i=i+1;
  20.         }
  21.         rata = jumlah/panjang;
  22.         System.out.println("Jumlah = "+jumlah);
  23.         System.out.println("rata-rata = "+rata);
  24.     }
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top