Modul 1. lat3


package prjmhsb;

/**
 *
 * @author LABOR MAT
 */
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
    public static void main(String[] args) {
        // TODO code application logic here
        BufferedReader InputData = new BufferedReader (new
                InputStreamReader(System.in));
        String Nama="";
        System.out.println("Input Nama : ");
        try{
            Nama =InputData.readLine();
        }catch(IOException e){System.out.println("error");
        }
        String Bp="";
        System.out.println("Input BP :");
        try{
            Bp = InputData.readLine();
        }catch(IOException e){System.out.println("Error");}
        
        String JuMat ="";
        System.out.println("Jumlah Matakuliah : ");
        try{
            JuMat = InputData.readLine();
        }catch(IOException e){System.out.println("Error");
        }
        //konversi string ke integer
        int Jum = Integer.valueOf(JuMat).intValue();
        // mendefinisikan variabel array
        String []MK = new String[Jum];
        String []SKS=new String[Jum];
        String []Nilai =new String[Jum];
        String []Nilhuruf = new String[Jum];
        int []mutu = new int[Jum];
        int jumMutu=0;
        int totMutu=0;
        int jumSks=0;
        int IP=0;
        
        for (int i = 0; i < Jum ; i++) 
        {
            System.out.println("Input MK :");
            try {
                MK[i]=InputData.readLine();
            }catch(IOException e){System.out.println("Error");
            }
            System.out.println("Input SKS :");
            try {
                SKS[i]=InputData.readLine();
            }catch(IOException e){System.out.println("Error");
            }
            System.out.println("Input Nilai : ");
            try{
                Nilai[i]=InputData.readLine();
            }catch(IOException e){System.out.println("error");
            }
        //Mengkondisikan Nilai angka menjadi nilai huruf
        //Konversi Nilai ke integer
            int Nilang = Integer.valueOf(Nilai[i]).intValue();
        //Logika if
                    if(Nilang > 80)
                    {Nilhuruf[i]="A";
                     mutu[i] =4;
                    }
                    else if(Nilang > 65)
                    {
                        Nilhuruf[i]="B";
                        mutu[i]=3;
                    }
                    else if(Nilang >55)
                    {
                        Nilhuruf[i]="C";
                        mutu[i]=2;
                    }
                    else if(Nilang >45)
                    {
                        Nilhuruf[i]="D";
                        mutu[i]=1;
                    }
                    else
                    {
                        Nilhuruf[i]="E";
                        mutu[i]=0;
                    }
            //Jumlah mutu
            int sks = Integer.valueOf(SKS[i]).intValue();
            
        jumMutu  = sks * mutu[i];
        //total JumMutu
        totMutu = totMutu + jumMutu;
                //total SKS
        jumSks = jumSks + sks;
        }
        IP = totMutu/jumSks;
                
        // menampilkan data
        System.out.println("Nama :" + Nama);
        System.out.println("BP   :" + Bp);
        System.out.println("Jumlah MK "+Jum);
        System.out.println("-------------------------------------------");
        System.out.println("No.  Nama MK   SKS    Nilai Angka Nilai Huruf Mutu");
        System.out.println("-------------------------------------------");
        for (int i = 0;i<Jum;i++) 
        {
            System.out.println((i+1)+" "+ MK[i] +" "+ SKS[i]+" "+ Nilai[i] +" "+mutu[i]);
        }
        System.out.println("Indeks Prestasi : " +IP);

}}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: