Program Java Array
Program Daftar Teman
import java.util.Scanner ;public class temankuuu {
public static void main(String[] args) {
String[] temansd = new String[2] ;
String[] temansmp = new String[2] ;
String[] temansma = new String[2] ;
Scanner input = new Scanner(System.in) ;
System.out.println("=Tuliskan Nama Teman Anda=") ;
for( int sd = 0; sd < temansd.length; sd++ ){
System.out.print("Teman SD = ") ;
temansd[sd] = input.nextLine() ;
}
for( int smp = 0; smp < temansmp.length; smp++ ){
System.out.print("Teman SMP = ") ;
temansmp[smp] = input.nextLine() ;
}
for( int sma = 0; sma < temansma.length; sma++ ){
System.out.print("Teman SMA = ") ;
temansma[sma] = input.nextLine() ;
}
System.out.println("=======DAFTAR TEMAN=======") ;
System.out.println("==========================") ;
System.out.println("======SEMUA TEMAN SD======") ;
for(String a : temansd) {
System.out.println("Teman SD = "+a) ;
}
System.out.println("======SEMUA TEMAN SMP======") ;
for(String b : temansmp) {
System.out.println("Teman SMP = "+b) ;
}
System.out.println("======SEMUA TEMAN SMA======") ;
for(String c : temansma) {
System.out.println("Teman SMA = "+c) ;
}
}
}
Output
Comments
Post a Comment