RSS

contoh program java memberi nilai ujian

04 May

public class NilaiUjian {
private String nama;
private double nilai;

public NilaiUjian (String anama, double anilai) {
nama = anama;
nilai = anilai;
}
public String KeteranganNilai() {
String Keterangan = “”;
if (nilai =90) {
Keterangan = “grade A”;
} else if (nilai=80) {
Keterangan = “grade B”;
} else if (nilai=70) {
Keterangan = “grade C”;
} else if (nilai=60) {
Keterangan = “grade D”;
} else if (nilai=0) {
Keterangan = “grade E”;
} else {
Keterangan = “Nilai tidak valid”;
}
return “nilai “+ nama +” = ” + nilai + ” ;KeteranganNilai = “+ Keterangan;
}
}

public class CobaNilaiUjian {
public static void main(String [] args) {
NilaiUjian nilaiUjian1 = new NilaiUjian(“Emha Taufiq L\t”,98.0);
NilaiUjian nilaiUjian2 = new NilaiUjian(“wahyu Sejati\t”,70.0);
NilaiUjian nilaiUjian3 = new NilaiUjian(“Agus Wibowo\t”,85.0);
NilaiUjian nilaiUjian4 = new NilaiUjian(“Ibnu Rosyadi\t”,55.0);
System.out.println(nilaiUjian1.KeteranganNilai());
System.out.println(nilaiUjian2.KeteranganNilai());
System.out.println(nilaiUjian3.KeteranganNilai());
System.out.println(nilaiUjian4.KeteranganNilai());
}
package com.pbo.java;
import java.util.*;
public class LuasLingkaran
{
public static void main(String args[]){
final double x=3.14;
double y;
double z;
Scanner in = new Scanner(System.in);
System.out.println(“”);
System.out.println(“Menghitung Luas Lingkaran …”);
System.out.print(“Masukan jari-jari :”);
y=in.nextDouble();
z=x*y*y;
System.out.println(“Luas = ” + z);
}
}

 

Tags:

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: