Materi Populer

Selasa, 26 April 2011

Program Nilai Rata-rata Sederhana dengan Input dengan Java

import java.io.*;

class Penilaian {
public static void main(String[] args) throws IOException {
BufferedReader bfr= new BufferedReader
(new InputStreamReader(System.in));
String x;
double absen,quis,tugas,UTS,UAS,x1,x2,x3,x4,x5,x6,x7,x8,a,b,c,d,e,f,g,h;
a=100/10;
b=90/10;
c=80/10;
d=50/10;
f=0.15;
g=0.25;
h=0.35;

System.out.print("Masukkan Nama Mahasiswa :");
x=bfr.readLine();


System.out.print("Masukkan Jumlah Absen :");
absen=Double.parseDouble(bfr.readLine());



System.out.print("Masukkan Jumlah Quis :");
quis=Double.parseDouble(bfr.readLine());

x1=quis*f;
System.out.print("Masukkan Jumlah Tugas :");
tugas=Double.parseDouble(bfr.readLine());

x2=tugas*f;
System.out.print("Masukkan Jumlah UTS :");
UTS=Double.parseDouble(bfr.readLine());


x3=UTS*g;
System.out.print("Masukkan Jumlah UAS :");
UAS=Double.parseDouble(bfr.readLine());
x4=UAS*h;



System.out.println("Nilai quis :"+x1);


System.out.println("Nilai Tugas :"+x2);

System.out.println("Nilai UTS :"+x3);


System.out.println("Nilai UAS :"+x4);
x5= a +x1 + x2 + x3 + x4;
x6= b +x1 + x2 + x3 + x4;
x7= c +x1 + x2 + x3 + x4;
x8= d +x1 + x2 + x3 + x4;

if (absen==0)
System.out.print("Nilai Keseluruhan :"+x5);


else if (absen==1)
System.out.print("Nilai Keseluruhan :"+x6);
else if (absen==2)
System.out.print("Nilai Keseluruhan :"+x7);
else
System.out.print("Nilai Keseluruhan :"+x8);

}

}

Jumat, 25 Maret 2011

Belajar Membuat tampilan GUI sederhana pada Pemrograman Java

Membuat tampilan GUI sederhana dengan Java

import javax.swing.JOptionPane;
class tingkat1
{
public static void main(String[] args)
{
//memasukkan angka
String angka_string;
angka_string = JOptionPane.showInputDialog(null,"Masukkan sebuah angka dari 100-0 :","ANGKA 0 - 100",
JOptionPane.QUESTION_MESSAGE);

//konversi angka ke integer
int angka;
angka = Integer.parseInt(angka_string);

String pesan;
//pemberian nilai huruf pada angka yg dimasukkan
if(angka>100)
{
pesan = "Anda pasti tidak membaca perintah !";
}
else if(angka>=90)
{
pesan = "Nilai anda A";
}
else if(angka>=70)
{
pesan = "Nilai anda B";
}
else if(angka>=60)
{
pesan = "Nilai anda C";
}
else if(angka>=50)
{
pesan = "Nilai anda D";
}
else
{
pesan = "anda tidak lulus";
}

//menampilkan hasil
JOptionPane.showMessageDialog(null, pesan, "NILAI ANDA",
JOptionPane.INFORMATION_MESSAGE);
}
}

Kamis, 16 Desember 2010

Membuat Program Data Mahasiswa Dengan Menggunakan Array pada Java

contoh program data Mahasiswa menggunakan Array pada Java Programing.
dengan cara menginputkan beberapa data mahasiswa yang di inputkan lebih dari 1


import java.io.*;
class Mahasiswa{
Mahasiswa(){
}
public void tampilMahasiswa() throws IOException{
int b,nim1,nim2,nim3,nim4,nim5,umur1,umur2,umur3,umur4,umur5;
String nama1,nama2,nama3,nama4,nama5,alamat1,alamat2,alamat3,alamat4,alamat5;

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


System.out.println("========================================================");
System.out.print("Masukkan Nim :");
nim1=Integer.parseInt(br.readLine());
System.out.print("Masukkan Nama:");
nama1=br.readLine();
System.out.print("Masukkan Umur:");
umur1=Integer.parseInt(br.readLine());
System.out.print("Masukkan Alamat :");
alamat1=br.readLine();
System.out.println("========================================================");
System.out.print("Masukkan Nim :");
nim2=Integer.parseInt(br.readLine());
System.out.print("Masukkan Nama:");
nama2=br.readLine();
System.out.print("Masukkan Umur:");
umur2=Integer.parseInt(br.readLine());
System.out.print("Masukkan Alamat :");
alamat2=br.readLine();
System.out.println("========================================================");
System.out.print("Masukkan Nim :");
nim3=Integer.parseInt(br.readLine());
System.out.print("Masukkan Nama:");
nama3=br.readLine();
System.out.print("Masukkan Umur:");
umur3=Integer.parseInt(br.readLine());
System.out.print("Masukkan Alamat :");
alamat3=br.readLine();
System.out.println("========================================================");
System.out.print("Masukkan Nim :");
nim4=Integer.parseInt(br.readLine());
System.out.print("Masukkan Nama:");
nama4=br.readLine();
System.out.print("Masukkan Umur:");
umur4=Integer.parseInt(br.readLine());
System.out.print("Masukkan Alamat :");
alamat4=br.readLine();
System.out.println("========================================================");
System.out.print("Masukkan Nim :");
nim5=Integer.parseInt(br.readLine());
System.out.print("Masukkan Nama:");
nama5=br.readLine();
System.out.print("Masukkan Umur:");
umur5=Integer.parseInt(br.readLine());
System.out.print("Masukkan Alamat :");
alamat5=br.readLine();
System.out.println("========================================================");

String[]nama={nama1,nama2,nama3,nama4,nama5};

String[]alamat={alamat1,alamat2,alamat3,alamat4,alamat5};

int[]nim={nim1,nim2,nim3,nim4,nim5};

int[]umur={umur1,umur2,umur3,umur4,umur5};

System.out.print("Masukkan Nim yang ingin di cari =");
b=Integer.parseInt(br.readLine());
if (b==nim[0]){
System.out.print("Nim Nomor ");
System.out.println(nim[0]);
System.out.print("Dimiliki oleh ");
System.out.println(nama[0]);
System.out.print("Umur :");
System.out.println(umur[0]);
System.out.print("Alamat :");
System.out.println(alamat[0]);
}else if(b==nim[1]){
System.out.print("Nim Nomor ");
System.out.println(nim[1]);
System.out.print("Dimiliki oleh ");
System.out.println(nama[1]);
System.out.print("Umur :");
System.out.println(umur[1]);
System.out.print("Alamat :");
System.out.println(alamat[1]);
}else if(b==nim[2]){
System.out.print("Nim Nomor ");
System.out.println(nim[2]);
System.out.print("Dimiliki oleh ");
System.out.println(nama[2]);
System.out.print("Umur :");
System.out.println(umur[2]);
System.out.print("Alamat :");
System.out.println(alamat[2]);
}else if(b==nim[3]){
System.out.print("Nim Nomor ");
System.out.println(nim[3]);
System.out.print("Dimiliki oleh ");
System.out.println(nama[3]);
System.out.print("Umur :");
System.out.println(umur[3]);
System.out.print("Alamat :");
System.out.println(alamat[3]);
}else if(b==nim[4]){
System.out.print("Nim Nomor ");
System.out.println(nim[4]);
System.out.print("Dimiliki oleh ");
System.out.println(nama[4]);
System.out.print("Umur :");
System.out.println(umur[4]);
System.out.print("Alamat :");
System.out.println(alamat[4]);
}else
System.out.print("Nim Yang Anda Masukkan Tidak Terdaftar");



}

}
class DataMahasiswa{
public static void main(String args[])throws IOException{

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

Mahasiswa stikom = new Mahasiswa();
stikom.tampilMahasiswa();


}
}
Dengan cara menginputkan nim = nomor induk mahasiswa untuk mencari data mahasiswa yang sudah di registrasi.