Advertisement
AldiDwik

Tugas 4

Nov 18th, 2020
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.62 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package array2dimensi;
  7. import java.util.Scanner;
  8. /**
  9.  *
  10.  * @author aldid
  11.  */
  12. public class Tugas4 {
  13.     public static void main(String[] args) {
  14.         Scanner input = new Scanner(System.in);
  15.         System.out.print("Masukkan Jumlah Baris Bangku : ");
  16.         int baris=input.nextInt();
  17.         System.out.print("Masukkan Jumlah Kolom Bangku : ");
  18.         int kolom=input.nextInt();
  19.         String[][]arraynama= new String[baris][kolom];
  20.         int[][]arraynilai=new int[baris][kolom];
  21.         for (int i = 0; i < baris; i++) {
  22.             for (int j = 0; j < kolom; j++) {
  23.                 System.out.print("Bangku ke - ["+i+"]["+j+"]");
  24.                 if(i==0 || j==0){
  25.                     System.out.print("Masukkan nama mahasiswa : ");
  26.                     arraynama[i][j]=input.nextLine();
  27.                 }
  28.                     else if(i==j){
  29.                             System.out.print("Masukkan nama mahasiswa : ");
  30.                             arraynama[i][j]=input.nextLine();
  31.                     }
  32.                             else{
  33.                         System.out.print("Masukkan nama mahasiswa : ");
  34.                         arraynama[i][j]=input.nextLine();
  35.                        
  36.                             }
  37.                 System.out.print("Masukkan Nilai Akhir : ");
  38.                 arraynilai[i][j]=input.nextInt();
  39.                 }
  40.                
  41.             }
  42.            
  43.         }
  44.        
  45.     }
  46.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement