menhitung nilai maha siswa

Rabu, 08 Juni 2011

menghitung nilai mhs

import java.util.Scanner;
public class Baru {
    public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        garis();
        System.out.println("            MENU PILIHAN                  ");
        garis();
        System.out.println("1. Menhitung Nilai Mahasiswa");
        System.out.println("");
        System.out.println("2. Exit");
        garis();
        System.out.println("");
        System.out.print("Anda pilih no   :");
        int pilih=input.nextInt();

        switch(pilih){
            case 1:{
               
                int[] npm=new int[20];
                String[] nama=new String[20];
                String[] jur=new String[20];
                String[] mk=new String[20];
                int[] n_tgas=new int[20];
                int[] n_uts=new int[20];
                int[] n_uas=new int[20];


                garis();
                System.out.println("    MENGHITUNG NILAI MAHASISWA");
                garis();
                System.out.println("");
                System.out.print("Masukan jumlah data ="); int n=input.nextInt();

                for(int i=1;i<=n;i++){
                    System.out.println("Data ke"+i +":");
                    System.out.print("NPM           :"); npm[i]=input.nextInt();
                    System.out.print("Nama          :"); nama[i]=input.next();
                    System.out.print("Jurusan       :"); jur[i]=input.next();
                    System.out.print("Mata Kuliah   :"); mk[i]=input.next();
                    System.out.print("Nilai tugas   :"); n_tgas[i]=input.nextInt();
                    System.out.print("Nilai UTS     :"); n_uts[i]=input.nextInt();
                    System.out.print("Nilai UAS     :"); n_uas[i]=input.nextInt();
                    double rata=(n_tgas[i]+n_uts[i]+n_uas[i])/3;
                    System.out.println("Nilai rata-rata ="+rata);

                }
                break;
                }
        default:System.exit(0);
        }
        }
static void garis(){
        System.out.println("==========================================");
    }
}



Outputnya
run:
==========================================
            MENU PILIHAN                 
==========================================
1. Menhitung Nilai Mahasiswa

2. Exit
==========================================

Anda pilih no   :1
==========================================
    MENGHITUNG NILAI MAHASISWA
==========================================

Masukan jumlah data =2
Data ke1:
NPM           :432
Nama          :aku
Jurusan       :ti
Mata Kuliah   :pm2
Nilai tugas   :80
Nilai UTS     :70
Nilai UAS     :87
Nilai rata-rata =79.0
Data ke2:
NPM           :434
Nama          :ina
Jurusan       :ti
Mata Kuliah   :pm1
Nilai tugas   :70
Nilai UTS     :80
Nilai UAS     :70
Nilai rata-rata =73.0

0 komentar:

Posting Komentar