Hello, can someone help me please ?
i'm newbie in programming, in this is the first time i use onlinegdb
i have test the simple code on java, if I compile in PC it works,
but if I run in onlinegdb, the output says :
Main.java:11: error: class Latihan is public, should be declared in a file named Latihan.java
public class Latihan {
^
1 error.
and the code as below :
import java.util.Scanner;
public class Latihan {
static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int totalMahasiswa = 0;
int totalNilai = 0;
int nilai = 0;
int rataRata = 0;
System.out.print("Masukan jumlah mahasiswa:");
totalMahasiswa = scanner.nextInt();
for(int i = 1; i <= totalMahasiswa; i++) {
System.out.print("Masukan nilai mahasiswa ke " + i + ":");
nilai = scanner.nextInt();
totalNilai = totalNilai + nilai;
}
rataRata = (totalNilai/totalMahasiswa);
System.out.println("Nilai rata-rata :" + rataRata);
}
}
please help, Thank you very much