package assignment1;
import java.util.Scanner;
class barang {
String judul;
String penerbit;
void databarang ()
{
Scanner input
= new Scanner (System.in);
System.out.println("DATA PENJUALAN BUKU");
System.out.println("");
System.out.print("Judul Buku : ");
judul =
input.nextLine();
System.out.print("Penerbit
: ");
penerbit =
input.nextLine();
System.out.println("");
System.out.println("");
}
}
class transaksi {
int jumlah;
int harga;
int total;
int diskon;
int uang;
int bayar;
int kembalian;
void
datatransaksi() {
Scanner input
= new Scanner (System.in);
System.out.println("DATA TRANSAKSI PENJUALAN BUKU");
System.out.println("");
System.out.print("Jumlah Buku Terjual : ");
jumlah =
input.nextInt();
System.out.print("Harga : Rp. ");
harga =
input.nextInt();
total =
jumlah*harga;
if (total>=150000)
{
System.out.println("Diskon : 10%");
diskon=(int) (total*0.1);
}
else {
diskon=0;
System.out.println("Diskon : 0%");
System.out.println("");
}
bayar =
total-diskon;
System.out.print("Total : Rp. "+bayar);
System.out.println("");
System.out.print("Jumlah Pembayaran : Rp. ");
uang =
input.nextInt();
if
(uang>=bayar) {
kembalian=uang-bayar;
System.out.print("Kembalian Uang Anda : Rp. "+kembalian);
System.out.println("");
System.out.println("");
}
else
System.out.println("UANG ANDA KURANG UNTUK MELAKUKAN PEMBAYARAN");
System.out.println("");
System.out.println("");
}
}
public class Assignment1 {
public static void
main(String[] args) {
Scanner input =
new Scanner (System.in);
String
perulangan="y";
while
("y".equals(perulangan))
{
barang brg = new
barang();
brg.databarang();
transaksi trs =
new transaksi();
trs.datatransaksi();
System.out.print("Apakah Ada Data Lainnya? [y/t] : ");
perulangan =
input.next();
System.out.println("");
System.out.println("");
}
}
}
CONTOH CODING JAVA MEBUAT GRAP PADA NEATBAENS 8.01
public static void
main(String[] args) {
Scanner input =
new Scanner(System.in);
Integer
baris,kolom,derajat=0;
boolean[][] x
= {
{false,false,false,false,false,true,false,true,false,true,false,true},
{true,false,false,false,true,false,false,false,false,false,true,true},
{false,true,false,false,false,false,false,false,true,true,true,false},
{false,false,true,false,false,false,true,true,true,false,false,false},
{false,false,false,true,true,true,true,false,false,false,false,false},
{true,true,true,true,false,false,false,false,false,false,false,false}
};
System.out.print("Input Baris(1-6) : ");
baris =
input.nextInt();
for
(kolom=0;kolom<12;kolom++){
if
(x[baris-1][kolom]!=false)
derajat=derajat+1;
}
System.out.println("Derajat = "+derajat);
}
}
package assignment1;
import java.util.Scanner;
class barang {
String judul;
String penerbit;
void databarang ()
{
Scanner input
= new Scanner (System.in);
System.out.println("DATA PENJUALAN BUKU");
System.out.println("");
System.out.print("Judul Buku : ");
judul =
input.nextLine();
System.out.print("Penerbit
: ");
penerbit =
input.nextLine();
System.out.println("");
System.out.println("");
}
}
class transaksi {
int jumlah;
int harga;
int total;
int diskon;
int uang;
int bayar;
int kembalian;
void
datatransaksi() {
Scanner input
= new Scanner (System.in);
System.out.println("DATA TRANSAKSI PENJUALAN BUKU");
System.out.println("");
System.out.print("Jumlah Buku Terjual : ");
jumlah =
input.nextInt();
System.out.print("Harga : Rp. ");
harga =
input.nextInt();
total =
jumlah*harga;
if (total>=150000)
{
System.out.println("Diskon : 10%");
diskon=(int) (total*0.1);
}
else {
diskon=0;
System.out.println("Diskon : 0%");
System.out.println("");
}
bayar =
total-diskon;
System.out.print("Total : Rp. "+bayar);
System.out.println("");
System.out.print("Jumlah Pembayaran : Rp. ");
uang =
input.nextInt();
if
(uang>=bayar) {
kembalian=uang-bayar;
System.out.print("Kembalian Uang Anda : Rp. "+kembalian);
System.out.println("");
System.out.println("");
}
else
System.out.println("UANG ANDA KURANG UNTUK MELAKUKAN PEMBAYARAN");
System.out.println("");
System.out.println("");
}
}
public class Assignment1 {
public static void
main(String[] args) {
Scanner input =
new Scanner (System.in);
String
perulangan="y";
while
("y".equals(perulangan))
{
barang brg = new
barang();
brg.databarang();
transaksi trs =
new transaksi();
trs.datatransaksi();
System.out.print("Apakah Ada Data Lainnya? [y/t] : ");
perulangan =
input.next();
System.out.println("");
System.out.println("");
}
}
}
OUTPUT PROGRAM
No comments:
Post a Comment