Java kuliah latihan input nilai mahasiswa

import java.util.Scanner;
import java.util.Formatter;
public class latihan_input_nilai_formatter{
 public static void main(String[] arg){
 Scanner inputan = new Scanner(System.in);
 
 int jum_mhs = 2;
 String vars[] = {"NPM","Nama","N. UTS","N. UAS","N. Praktikum","Nilai Akhir"};
 String a[][] = new String[jum_mhs][vars.length];
 
 for(int i = 0;i<=jum_mhs-1;i++){
 for(int j = 0;j<vars.length;j++){
 System.out.print("Masukkan "+vars[j]+" mahasiswa ke-"+(i+1)+" : ");
 a[i][j] = inputan.next();
 }
 } 
 System.out.format("|%-15s|%-20s|%-12s|%-12s|%-12s|%-12s|", vars[0], vars[1], vars[2],vars[3],vars[4],vars[5]);
 for(int i = 0;i<=jum_mhs-1;i++){
 System.out.println("");
 System.out.format("|%-15s|%-20s|%-12s|%-12s|%-12s|%-12s|", a[i][0], a[i][1], a[i][2],a[i][3],a[i][4],a[i][5]);
 }
 }
}

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *