IKHWANNUDIN 1655201033
TEKNIK INFORMATIKA
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package aray2dimensi;
import java.util.Scanner;
/**
*
* @author ikhwan
*/
public class ARAY2DIMENSI {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String[][] array = new String[4][4];
int cek;
String bintang = "";
for(int i=0;i<array.length;i++){
for(int j=0;j<array.length;j++){
System.out.print("Input Angka baris["+i+"]"+" kolom["+j+"]= ");
array[i][j] = scan.next();
}
System.out.println("\n");
}
System.out.println("\n");
System.out.println("Hasil Nilai Inputan");
for (String[] array1 : array) {
for (int j = 0; j<array.length; j++) {
System.out.print("|" + array1[j] + "|");
bintang = array1[j];
cek = bintang.indexOf("4");
array1[j] = cek>=0 ? "**" : array1[j];
}
System.out.println("");
}
System.out.println("------------------------------------");
System.out.println("");
System.out.println("Hasil Nilai Berubah");
for (String[] array1 : array) {
for (int j = 0; j<array.length; j++) {
System.out.print("|" + array1[j] + "|");
}
System.out.println();
}
}
}
Tidak ada komentar:
Posting Komentar