package vehicle;
/**
* Copyright @ 2013 - Muhammad Kh. Umam
* 2 Rpl 1
*/
public class Vehicle {
String owner, color, merk;
int wheel, speed;
void Owner(String o, int w){
owner=o;
wheel=w;
}
void Type(String c, String m, int s){
color=c;
merk=m ;
speed=s;
}
static void Line(){
System.out.println("+-------------------------------------+");
}
void Show(){
Line();
System.out.println("Nama Pemilik : "+owner);
System.out.println("Jumlah Roda : "+wheel);
System.out.println("Warna : "+color);
System.out.println("Merk : "+merk);
System.out.println("Speed : "+speed+" km/jam");
}
public static void main(String[] args){
Vehicle Motor = new Vehicle();
Motor.Owner ("Al-Umam Nipponizer",2);
Motor.Type("Biru Muda","Jupiter Z",250);
Motor.Show();
Vehicle Mobil = new Vehicle();
Mobil.Owner ("Muhammad Kh. Umam",4);
Mobil.Type("Biru Langit","Nissan Skyline GT-R34",350);
Mobil.Show();
Line();
System.out.println();
for(int i =0; i<= 100; i++){
System.out.println("Mobil melaju dengan kecepatan "+i+" km/jam");
if (i==100){
break;
}
}
System.out.println();
// Pengeremman
for(int a = 100; a >= 0 ; a--){
System.out.println("Kecepatan mobil menurun sampai "+a+" km/jam");
if (a==0){
break;
}
}
}
}
Screenshoot ketika program di jalankan (running program) :
Sumber referensi :
- Modul "Belajar Java Dasar"
- Contoh Program Ketika Praktek di Sekolahan
0 comments:
Post a Comment