/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package oopcoy1;
class Motorcycle{
/**
*
* @author hadiid
*/
double speed;
int capacity;
double fuel;
public Motorcycle(){
System.out.println("Motorcycle object is created...");
}
public Motorcycle (double f){
fuel =f;
System.out.println("Motorcycle object is created with"+fuel+"fuel");
}
public void accelerated (double a, int t, int cpc){
speed = a*t;
capacity = cpc;
if (speed>150){
speed = 150;
System.out.println("Speed is maximum ...");}
if (capacity > 150){
capacity = 150;
System.out.println("Capacity is maximum...");}
fuel = fuel-0.001*a*t;
System.out.println("Speed ="+speed);
System.out.println("Capacity ="+capacity);}
public String GetInfo(){
String tmp = "Motorcycle status=\n";
tmp=tmp + "Speed ="+speed;
tmp = tmp +"fuel="+fuel;
tmp = tmp +"capacity ="+capacity;
return tmp;
}
public double getSpeed (){return speed;}
public int getCapacity() {return capacity;}
public void setFuel(double f)
{
if (f<=1000){
fuel=fuel+f;
}
else
System.out.println("Fuel over speed...");
}
}
public class Oopcoy1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Motorcycle myMotorcycle = new Motorcycle(50);
myMotorcycle.accelerated (5,50,100);
System.out.println("Now Speed is"+myMotorcycle.getSpeed());
System.out.println("Now capacity is"+myMotorcycle.getCapacity());
myMotorcycle.GetInfo();
myMotorcycle.setFuel(150);
myMotorcycle.GetInfo();
}
}
Senin, 28 Desember 2015
Rabu, 11 November 2015
array
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package array;
import java.util.Scanner;
/**
*
* @author hadiid
*/
public class Array {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner van = new Scanner(System.in);
int brg;
System.out.print("Input item = ");
brg = van.nextInt();
String nama[] = new String[brg];
int hrg[] = new int[brg];
int jml[] = new int[brg];
int ttl[] = new int[brg];
int ttl1 = 0;
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package array;
import java.util.Scanner;
/**
*
* @author hadiid
*/
public class Array {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner van = new Scanner(System.in);
int brg;
System.out.print("Input item = ");
brg = van.nextInt();
String nama[] = new String[brg];
int hrg[] = new int[brg];
int jml[] = new int[brg];
int ttl[] = new int[brg];
int ttl1 = 0;
Senin, 09 November 2015
Sabtu, 03 Oktober 2015
tugas 3
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package diskonpakjoko;
/**
*
* @author hadiid
*/
import java.util.Scanner;
public class Diskonpakjoko {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int jumlah;
//double harga;
double biaya;
double diskon;
// TODO code application logic here
System.out.println("********************************************");
System.out.println("* *");
System.out.println("* Hadiidstore *");
System.out.println("* Menyediakan barang-barang elektronik *");
System.out.println("* *");
System.out.println("********************************************");
System.out.println();
System.out.println("Daftar barang Toko Hadiid");
System.out.println("1. Wireless Mouse\n2. Keyboard\n3. Printer");
System.out.println("4. Flashdisk\n.5. Laptop\n");
System.out.println();
System.out.println("Pilihan Anda: ");
int pilih = sc.nextInt();
switch (pilih){
case 1: System.out.println("Wireless Mouse Logitech");
System.out.println("Rp. 50.000,00");
System.out.println("Pesan berapa? ");
jumlah = sc.nextInt();
biaya = 50000*jumlah;
System.out.println("Biaya = Rp. "+biaya);
if (biaya >= 250000)
{
diskon = 0.05;
}
else if (biaya >= 150000)
{
diskon = 0.02;
}
else{
diskon = 0;
}
System.out.println("Diskon sebesar = "+biaya*diskon);
biaya = biaya - (biaya*diskon);
System.out.println("Biaya setelah diskon = Rp. "+biaya);
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package diskonpakjoko;
/**
*
* @author hadiid
*/
import java.util.Scanner;
public class Diskonpakjoko {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int jumlah;
//double harga;
double biaya;
double diskon;
// TODO code application logic here
System.out.println("********************************************");
System.out.println("* *");
System.out.println("* Hadiidstore *");
System.out.println("* Menyediakan barang-barang elektronik *");
System.out.println("* *");
System.out.println("********************************************");
System.out.println();
System.out.println("Daftar barang Toko Hadiid");
System.out.println("1. Wireless Mouse\n2. Keyboard\n3. Printer");
System.out.println("4. Flashdisk\n.5. Laptop\n");
System.out.println();
System.out.println("Pilihan Anda: ");
int pilih = sc.nextInt();
switch (pilih){
case 1: System.out.println("Wireless Mouse Logitech");
System.out.println("Rp. 50.000,00");
System.out.println("Pesan berapa? ");
jumlah = sc.nextInt();
biaya = 50000*jumlah;
System.out.println("Biaya = Rp. "+biaya);
if (biaya >= 250000)
{
diskon = 0.05;
}
else if (biaya >= 150000)
{
diskon = 0.02;
}
else{
diskon = 0;
}
System.out.println("Diskon sebesar = "+biaya*diskon);
biaya = biaya - (biaya*diskon);
System.out.println("Biaya setelah diskon = Rp. "+biaya);
Rabu, 23 September 2015
tugas
package tokopakjoko15;
import java.util.Scanner;
public class Tokopakjoko15 {
public static void main(String[] args) {
// TODO code application logic here
int Harga, Jumlah, Biaya;
System.out.println("**********************************");
System.out.println("* Toko Pak Joko *");
System.out.println("* menyediakan barang sehari-hari *");
System.out.println("**********************************");
System.out.println();
System.out.println("kami menjual beras 15000/kg");
System.out.println();
//System.out.println("beras 3kg harganya =Rp. "+3*15000);
Harga=20000; Jumlah=3;
Biaya = Harga*Jumlah;
System.out.println("Biaya="+Biaya);
Harga=100000; Jumlah=100;
Biaya = Harga*Jumlah;
System.out.println("Biaya="+Biaya+"\n");
Scanner input = new Scanner(System.in);
String nama;
int harga, jumlah, biaya;
System.out.println("Nama Barang:");
nama = input.next();
System.out.println("Harga Barang:");
harga = input.nextInt();
System.out.println("Jumlah Pembelian:");
jumlah = input.nextInt();
biaya = jumlah*harga;
System.out.println("Biaya total Rp. "+biaya);
}
}
import java.util.Scanner;
public class Tokopakjoko15 {
public static void main(String[] args) {
// TODO code application logic here
int Harga, Jumlah, Biaya;
System.out.println("**********************************");
System.out.println("* Toko Pak Joko *");
System.out.println("* menyediakan barang sehari-hari *");
System.out.println("**********************************");
System.out.println();
System.out.println("kami menjual beras 15000/kg");
System.out.println();
//System.out.println("beras 3kg harganya =Rp. "+3*15000);
Harga=20000; Jumlah=3;
Biaya = Harga*Jumlah;
System.out.println("Biaya="+Biaya);
Harga=100000; Jumlah=100;
Biaya = Harga*Jumlah;
System.out.println("Biaya="+Biaya+"\n");
Scanner input = new Scanner(System.in);
String nama;
int harga, jumlah, biaya;
System.out.println("Nama Barang:");
nama = input.next();
System.out.println("Harga Barang:");
harga = input.nextInt();
System.out.println("Jumlah Pembelian:");
jumlah = input.nextInt();
biaya = jumlah*harga;
System.out.println("Biaya total Rp. "+biaya);
}
}
Langganan:
Postingan (Atom)
