Quick actions

cmd+k|ctrl+k

Navigation

Languages

Latihan 1

Snippet info

Language

Java

Visibility

public

Author

fauziramdan44

Created

2023-06-09T07:20:40.371119Z

Updated

2023-06-09T07:20:40.371119Z

import java.text.DecimalFormat;
class Main {
    public static void main(String[] args) {
        int[][] mhs = {{81, 90, 62},{50, 83, 87},{89, 55, 65},{77, 70, 92}};
        System.out.println("NRP\tRata-rata");
        System.out.println("----------------");
        for(int i = 0; i < mhs.length; i++) {
            System.out.print(i+1 + "\t");
            double rt = 0;
            for(int j = 0; j < mhs[i].length; j++) {
                rt = rt + mhs[i][j];
            }
            DecimalFormat df = new DecimalFormat("#.##");
            System.out.println(df.format(rt / mhs[i].length));
        }
    }
}
INFO