ARRAY22.CUTTARI PUNYA BARANG

/*
 * 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 tugas;

import java.util.Scanner;

/**
 *
 * @author guruh
 */
public class tugaspakdosen
{
     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(int i=0;i<array.length;i++){
            for(int j=0;j<array.length;j++){
    System.out.print("|"+array[i][j]+"|");
                                bintang = array[i][j];
          cek = bintang.indexOf("4");
    array[i][j] = cek>=0?"**":array[i][j];
   }
   System.out.println("");
  }
                System.out.println("------------------------------------");
                System.out.println("");
                System.out.println("Hasil Nilai Berubah");
            for(int i=0;i<array.length;i++){
           
            for(int j=0;j<array.length;j++){
    System.out.print("|"+array[i][j]+"|");
   }
   System.out.println();
  }
 }
}






Komentar