view plainprint?
package autocar;
import java.util.Scanner;
/**
* @Copyright 2013 http://kelimlimm.blogspot.com
* @author halim
* 2 RPL 1
*/
class Kendaraan {
String pemilik,warna,merek,jenis;
int roda,speed;
void lihatdata() {
System.out.println("Nama Pemilik : "+pemilik);
System.out.println("Roda : "+roda);
System.out.println("Merek : "+merek);
System.out.println("Jenis : "+jenis);
System.out.println("Warna : "+warna);
System.out.println("Kecepatan : "+speed+" km/h");
System.out.println("");
}
String Getpemilik() {
return pemilik;
}
String Getwarna() {
return warna;
}
String Getmerek(){
return merek;
}
String Getjenis(){
return jenis;
}
Integer Getroda(){
return roda;
}
Integer Getspeed(){
return speed;
}
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
Kendaraan Moto = new Kendaraan();
Kendaraan Car = new Kendaraan();
int i,j,whl=1,kecepatan,pilih; //Variabel untuk for
Moto.pemilik = "Ucup"; //Mengisi Variabel Motor
Moto.roda = 2 ;
Moto.merek = "Honda";
Moto.jenis = "Supra PIT" ;
Moto.warna = "Hitam comberan";
Moto.speed = 100;
Car.pemilik = "Junaedi"; //Mengisi variabel Mobil
Car.roda = 4;
Car.merek = "Suzuki";
Car.jenis = "Carry";
Car.warna = "Merah luntur";
Car.speed = 150;
//Maaf saya plesetin kalo misal kurang berkenan bisa anda edit ^_^
Moto.lihatdata(); //Menampilkan Data Motor
Car.lihatdata(); //Menampilkan Data Mobil
while(whl==1) {
System.out.println("Pilih hitung kecepatan "
+ "\n 1. Hit kecepatan Mobil = ketik '1' "
+ "\n 2. Hit kecepatan Motor = ketik '2' "
+ "\n 3. Exit = ketik '3'");
pilih = inp.nextInt();
if (pilih==1) { //pilih hitung kecepatan mobil
//Melaju
System.out.println("Masukan Max Kecepatan : ");
kecepatan = inp.nextInt();
if( kecepatan <=Car.speed ){ //kecepatan normal
System.out.println("=>Mobil melaju");
for(i=0; i<=kecepatan;i++ ) {
System.out.println("Mobil melaju dengan kecepatan "+i+" km/h");
if (i==kecepatan)
break;
}
System.out.println("");
System.out.println("=>Mobil melakukan pengereman");
//Melakukan pengereman
for(j=kecepatan ;j>=0; j--){
System.out.println("Mobil melambat dengan kecepatan "+j+" km/h");
if (j==0)
System.out.println("=>Mobil berhenti*");
whl=0;
}
} if ((kecepatan>=Car.speed)) { //kecepatan di atas normal
System.out.println("! Maaf kecepatan tidak lebih dari 150 km/h");
System.out.println("");
whl=1;
}
} if (pilih == 2){ //pilih hitung kecepatan motor
System.out.println("Masukan Max Kecepatan : ");
kecepatan = inp.nextInt();
if( kecepatan <=Moto.speed ){ //kecepatan normal
System.out.println("=>Mobil melaju");
for(i=0; i<=kecepatan;i++ ) {
System.out.println("Mobil melaju dengan kecepatan "+i+" km/h");
if (i==kecepatan)
break;
}
System.out.println("");
System.out.println("=>Mobil melakukan pengereman");
//Melakukan pengereman
for(j=kecepatan ;j>=0; j--){
System.out.println("Mobil melambat dengan kecepatan "+j+" km/h");
if (j==0)
System.out.println("=>Motor berhenti");
whl=0;
}
} if (kecepatan >= Moto.speed) { //kecepatan diatas normal
System.out.println("! Maaf kecepatan tidak lebih dari 100 km/h");
System.out.println("");
whl=1;
}
inilah sreenshotnya
} if (pilih == 3){ //Exit
System.out.println("Exit Succes");
whl=0;
}
}
}
}
This is default featured slide 1 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.
This is default featured slide 2 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.
This is default featured slide 3 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.
This is default featured slide 4 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.
This is default featured slide 5 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.
Rabu, 15 Mei 2013
07.41
No comments













