PROGRAM ARRAY NILAI MAHASISWA
package array_munif;
/**
*
* @author munif
*/
import java.util.Scanner;
public class Array_Munif
{
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int n, jml, nilai[];
float rata, jumlah = 0;
System.out.println("\n\tPROGRAM NILAI MAHASISWA By MUNIF IF16C");
System.out.print("\nMasukkan Jumlah Mahasiswa : ");
n = input.nextInt();
System.out.println();
nilai = new int[n];
for(int i=0; i<n; i++)
{
System.out.print("Nilai Mahasiswa " + (i+1) + " : ");
nilai[i] = input.nextInt();
}
for(int j=0; j<n; j++)
{
jumlah = jumlah + nilai[j];
}
rata = jumlah/n;
System.out.println("\nJumlah Total Nilai \t= "+jumlah);
System.out.println("Nilai rata-rata kelas \t= " + rata+"\n");
}
}
No comments:
Post a Comment