import java.io.*;
class InputDataArray{
public static void main (String [ ]args ) {
DataInputStream
input = new DataInputStream (System.in);
try
int [ ]angka = new int [5];
System.out.println
(“ Masukkan “+ angka.length+ “data angka”);
System.out.println (“-------------------------------------------“ );
for (int i=0;i<angka.length;i++)
{
System.out.print (“data ke –“ + (i+1)+”:”);
angka [i] = Integer.parseInt (input.readLine ());
}
System.out.println
(“cetak isi Variabel Angka)
for (int i=0; i<angka.length; i++)
System.out.print
(“Data pada elemen ke –“+i+”:”+angka[i]);
System.out.println(“Input
angka yang di cari”);
boolean ketemu = false;
int cari = Integer.parseInt (input.readLine());
for (int i=0; i<angka.length; i++) {
If angka [i] == cari
ketemu = true;
}
if ketemu == true;
System.out.println (“Data yang dicari ketemu”);
}
Catch (Exception
e) {
System.out.println
(“Input salah”);
}
}
Tidak ada komentar:
Posting Komentar