Soal Latihan 1 : Menghitung Nilai Mahasiswa menggunakan Java


Soal:

Buat sebuah program sederhana untuk menerima input npm, nama, alamat, nilai absen, tugas, uts dan uas. Dan tampilkan kembali dalam bentuk npm, nama, alamat, nilai absen, tugas, uts, uas, total nilai angka (NA=absen+30%*tugas+30%*uts+30%*uas), nilai huruf. (dgn range tiap nilai adalah 20). Nilai Absen = 10 jika absen > 10 klo <= 10 maka Nilai Absen = 0

Salah satu Jawaban:

/*
	Sodiq1.java
*/
import java.util.Scanner;

class Sodiq1{
	public static void main(String[] args)
	{
		Scanner scansod = new Scanner(System.in);

		System.out.print("Npm          : "); String npm = scansod.nextLine();
		System.out.print("Nama         : "); String nm = scansod.nextLine();
		System.out.print("Alamat       : "); String alamat = scansod.nextLine();
		System.out.print("Absen        : "); double absen = scansod.nextDouble();
		System.out.print("Tugas        : "); double tugas = scansod.nextDouble();
		System.out.print("Uts          : "); double uts = scansod.nextDouble();
		System.out.print("Uas          : "); double uas = scansod.nextDouble();
		System.out.println("--------------------------------------");
		if(absen > 10) absen=10;
		else absen=0;
		double NA;
		NA=absen+(0.3*tugas)+(0.3*uts)+(0.3*uas);
		System.out.println("Npm          : "+npm);
		System.out.println("Nama         : "+nm);
		System.out.println("Alamat       : "+alamat);
		System.out.println("Absen        : "+absen);
		System.out.println("Tugas        : "+tugas);
		System.out.println("Uts          : "+uts);
		System.out.println("Uas          : "+uas);
		System.out.println("Nilai Akhir  : "+NA);
		if(NA>=80)System.out.println("Grade        : A");
		else if(NA<80 && NA >=60)System.out.println("Grade        : B");
		else if(NA<60 && NA >=40)System.out.println("Grade        : C");
		else if(NA<40 && NA >=20)System.out.println("Grade        : D");
		else if(NA<20)System.out.print("Grade        : E");
	}
}

Sourcecode: 4shared or Ziddu

Bookmark and Share Subscribe

About these ads

5 thoughts on “Soal Latihan 1 : Menghitung Nilai Mahasiswa menggunakan Java

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