Cari yg kamu Butuhkan Di Sini
Mengenai Saya
Arsip Blog
-
▼
2014
(30)
-
▼
September
(12)
- Program " Baca Array "
- Program " Rata-rata Bilangan "
- Program " Panjang, Lebar & Luas "
- Program " Hello "
- Selamat Datang Di Entri IT
- Selamat Datang Di Entri Sejarah
- Selamat Datang Di Entri Psikologi
- Selamat Datang Di Entri Inspiratif
- Selamat Datang Di Entri Belajar Gambar
- Selamat Datang Di Entri Tokoh
- Selamat Datang Di Entri Blogger
- Selamat Datang Di Entri Lain-lain
-
▼
September
(12)
Total Tayangan Halaman
import javax.swing.*;
class BacaArray
{
public static void main(String[] args)
{ int max = -9999, min = 99999, tot = 0, i;
int[] A = new int[6];
System.out.println("Masukkan ke-6 elemen array A ... ");
for (i=0;i<=5;i++)
{
String sbil = JOptionPane.showInputDialog(null,"Bilangan ke-"+(i+1));
A[i] = Integer.parseInt(sbil);
if (A[i] > max) max = A[i];
if (A[i] < min) min = A[i];
tot += A[i];
}
System.out.print("\nA = [");
for (i=0;i<=5;i++)
{ System.out.print(" "+A[i]);
}
System.out.println(" ]\n\nElemen terbesar = " +max);
System.out.println("Elemen terkecil = " +min);
System.out.println("Total elemen = "+tot);
System.out.println("Rata-rata elemen = "+((float)(tot)/6));
}
}
class BacaArray
{
public static void main(String[] args)
{ int max = -9999, min = 99999, tot = 0, i;
int[] A = new int[6];
System.out.println("Masukkan ke-6 elemen array A ... ");
for (i=0;i<=5;i++)
{
String sbil = JOptionPane.showInputDialog(null,"Bilangan ke-"+(i+1));
A[i] = Integer.parseInt(sbil);
if (A[i] > max) max = A[i];
if (A[i] < min) min = A[i];
tot += A[i];
}
System.out.print("\nA = [");
for (i=0;i<=5;i++)
{ System.out.print(" "+A[i]);
}
System.out.println(" ]\n\nElemen terbesar = " +max);
System.out.println("Elemen terkecil = " +min);
System.out.println("Total elemen = "+tot);
System.out.println("Rata-rata elemen = "+((float)(tot)/6));
}
}
Langganan:
Postingan
(Atom)
Diberdayakan oleh Blogger.