import java.util.scanner;
public class Quiz
{
public static void main(string[]args)
{
scanner input=new scanner (system.in);
int pil;
garis();
system.out.println("menu latihan");
garis();
system.out.println("1. menghitung nilai mahasiswa");
system.out.println("2. exit");
garis();
system.out.print("anda pilih nomor:"); pil-input.nextin();
switch (pil)
{
case 1;
{
int[] data=new int[10];
double rata=0;
system.out.println(" ");
garis();
system.out.println(" menghitung nilai mahasiswa ");
garis();
system.out.println(" masukan jumlah mahasiswa: "); int n-input.nextin();
for (int i=2; i<=n; i++)
{
system.out.println( " nama : " ) ; string nama=input.next();
system.out.println( " jurusan : " ) : string jur=input.next();
system.out.println( " mata kuliah : " ) ; string mat=input.next();
system.out.println( " nilai tugas : " ) ; int tug=input.nextint();
system.out.println( " nilai uts : " ) ; int uts=input.nextint();
system.out.println( " nilai uas : " ) ; int uas=input.nextint();
rata=tugas+uts+uas;
system.out.print(" nilai rat : "+(rata/3));
system.out.println("\n");
}
break;
}
default:system.exit(0);
}
static void garis()
{
system.out.println("===================");
}
}
grunge.grunch.grung (Fajar TI 2A)
Rabu, 08 Juni 2011
Rabu, 11 Mei 2011
hasil dari for
import java.util.Scanner;
public class Pernyataan_FOR {
public static void main(String[]args){
int awal,akhir;
Scanner input=new Scanner(System.in);
System.out.print("masukan nilai awal= ");
awal=input.nextInt();
System.out.print("masukan nilai akhir= ");
akhir=input.nextInt();
System.out.print("bilangan dari 10 s/d 20 adalah :");
for(int i=awal;i
if(i%2==1)
System.out.print(i+"*");
}
}
ini hasilnya
run:
masukan nilai awal= 10
masukan nilai akhir= 20
bilangan dari 10 s/d 20 adalah :11*13*15*17*19* BUILD SUCCESSFUL (total time: 7 seconds)
import java.util.Scanner;
public class Pernyataan_FOR {
public static void main(String[]args){
int awal,akhir;
Scanner input=new Scanner(System.in);
System.out.print("masukan nilai awal= ");
awal=input.nextInt();
System.out.print("masukan nilai akhir= ");
akhir=input.nextInt();
System.out.print("bilangan dari 10 s/d 20 adalah :");
for(int i=awal;i
if(i%2==1)
System.out.print(i+"*");
}
}
ini hasilnya
run:
masukan nilai awal= 10
masukan nilai akhir= 20
bilangan dari 10 s/d 20 adalah :11*13*15*17*19* BUILD SUCCESSFUL (total time: 7 seconds)
hasil dari FOR
import java.util.Scanner;
public class a
{
public static void main(String[] args)
{
int data;
Scanner input=new Scanner (System.in);
System.out.print("Jumlah data = "); data=input.nextInt();
for(int i=1; i<=data; i++)
{
System.out.println("NPM");
System.out.println("Nama");
System.out.println("Jurusan\n");
}
}
}
hasilnya adalah....
run:
Jumlah data = 5
NPM
Nama
Jurusan
NPM
Nama
Jurusan
NPM
Nama
Jurusan
NPM
Nama
Jurusan
NPM
Nama
Jurusan
BUILD SUCCESSFUL (total time: 6 seconds)
import java.util.Scanner;
public class a
{
public static void main(String[] args)
{
int data;
Scanner input=new Scanner (System.in);
System.out.print("Jumlah data = "); data=input.nextInt();
for(int i=1; i<=data; i++)
{
System.out.println("NPM");
System.out.println("Nama");
System.out.println("Jurusan\n");
}
}
}
hasilnya adalah....
run:
Jumlah data = 5
NPM
Nama
Jurusan
NPM
Nama
Jurusan
NPM
Nama
Jurusan
NPM
Nama
Jurusan
NPM
Nama
Jurusan
BUILD SUCCESSFUL (total time: 6 seconds)
Rabu, 30 Maret 2011
Territorial Pissings lyrics
Come on people now, smile on your brother
Everybody get together, try to love one another right now
When I was an alien
Cultures weren't opinions
Gotta find a way, find a way when I'm there
Gotta find a way, a better way, better wait
Never met a wise man
If so it's a woman
Gotta find a way to find a way when I'm there
Gotta find a way, a better way, I better wait
Gotta find a way to find a way when I'm there
Gotta find a way, a better way, I better wait
[ From: http://www.elyrics.net/read/n/nirvana-lyrics/territorial-pissings-lyrics.html ]
Just because you're paranoid
Don't mean they're not after you
Gotta find a way to find a way when I'm there
Gotta find a way, a better way, I better wait
Gotta find a way to find a way when I'm there
Gotta find a way, a better way, I better wait
Gotta find a way to find a way when I'm there
Gotta find a way, a better way, I better wait
Come on people now, smile on your brother
Everybody get together, try to love one another right now
When I was an alien
Cultures weren't opinions
Gotta find a way, find a way when I'm there
Gotta find a way, a better way, better wait
Never met a wise man
If so it's a woman
Gotta find a way to find a way when I'm there
Gotta find a way, a better way, I better wait
Gotta find a way to find a way when I'm there
Gotta find a way, a better way, I better wait
[ From: http://www.elyrics.net/read/n/nirvana-lyrics/territorial-pissings-lyrics.html ]
Just because you're paranoid
Don't mean they're not after you
Gotta find a way to find a way when I'm there
Gotta find a way, a better way, I better wait
Gotta find a way to find a way when I'm there
Gotta find a way, a better way, I better wait
Gotta find a way to find a way when I'm there
Gotta find a way, a better way, I better wait
Rabu, 23 Maret 2011
Coding java pada konsep encapsulation
public class Gaji {
public int Gaji_Total= 0; // Data yang dapat diases dari luar diberi modifier
private int Gaji_Murni= 0; //data yang tidak dapat diases dari luar
public void Cetak1(){System.out.println("Gaji Total= "+ Gaji_Total);}
public void setGaji_Murni(int n){Gaji_Murni= n;}
public void Cetak2()
{System.out.println("Gaji_Murni= "+Gaji_Murni);}
}
public class GajiKu {
public static void main(String[] arg)
{Gaji Dt=new Gaji();
Dt.Gaji_Total=2500000;
Dt.Cetak1();
}
}
Menghitung luas lingkaran
public class lingkaran
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
double phi = 3.14;
double r, luas;
System.out.println("Program Luas Lingkaran\n");
System.out.print("Masukkan Panjang Jari-jari : ");
r = input.nextDouble();
luas = 0.5 * phi * r * r;
System.out.print("Luas Lingkaran = " + luas + "\n\n");
}
}
public class lingkaran
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
double phi = 3.14;
double r, luas;
System.out.println("Program Luas Lingkaran\n");
System.out.print("Masukkan Panjang Jari-jari : ");
r = input.nextDouble();
luas = 0.5 * phi * r * r;
System.out.print("Luas Lingkaran = " + luas + "\n\n");
}
}
Langganan:
Postingan (Atom)