Rata-Rata Nilai mengunakan java

Posted on Updated on

import java.io.*;

public class rataratanilai
{
public static void main(String [] args){

BufferedReader dataIn = new BufferedReader
(new InputStreamReader(System.in));

int nilaitugas;
int nilaiulangan;
int nilaiuas;
int nilaiabsen;
int proses;

try {
System.out.print(“Silahkan masukan nilai Tugas : “);
nilaitugas = Integer.parseInt(dataIn.readLine());

System.out.print(“Silahkan masukan nilai Ulangan : “);
nilaiulangan = Integer.parseInt(dataIn.readLine());

System.out.print(“Silahkan masukan nilai UAS : “);
nilaiuas = Integer.parseInt(dataIn.readLine());

System.out.print(“Silahkan masukan nilai Absen : “);
nilaiabsen = Integer.parseInt(dataIn.readLine());

//proses penghitungannya sebagai berikut
proses = ((nilaitugas + nilaiulangan + nilaiuas + nilaiabsen)/4);

//menampilkan hasilnya sebagai berikut
System.out.println(“————————————-“);
System.out.println(“-         Nilai Rata-Rata           -“);
System.out.println(“Nilai Tugas           : ” + nilaitugas);
System.out.println(“Nilai Ulangan       : ” + nilaiulangan);
System.out.println(“Nilai UAS               : ” + nilaiuas);
System.out.println(“Nilai Absen           : ” + nilaiabsen);
System.out.println(“————————————-“);
System.out.println(“Nilai Rata-Rata           : ” + proses);
System.out.println();

//kondisi Lulus dan Gagal sebagai berikut
if (proses>=60){
System.out.println(“LULUS”);
} else {
System.out.println(“GAGAL”);
}
} catch (IOException e){
System.out.println(“error input”);
}
}
}

hasil prinscreen

Advertisements

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