/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Administrator
*/
public class SequentialSearch {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String inputan = JOptionPane.showInputDialog(null, "Masukan Nilai perhitungan (pisah dengan koma)");
String temp[]=inputan.split(",");
String cari= JOptionPane.showInputDialog(null, "Cari Nilai");
int index=0;
boolean a=false;
while(!a && index<temp.length){
if(Integer.parseInt(cari)==Integer.parseInt(temp[index])){
a=true;
}
index++;
}
if(a==true){
System.out.println("Nilai Perhitungan "+inputan);
System.out.println("angka "+cari+" ada pada index ke "+(index));
}else
System.out.println("Nilai "+cari+" Tidak Ditemukan");
}
}
Posted by 14.57 and have
0
komentar
, Published at
Tidak ada komentar:
Posting Komentar