Thursday, June 6, 2013
Bingkai Pada Nama
Source Code :
public class Bingkai{
public static void main (String [] str){
String nama;
int panjang;
System.out.print("\nNAMA : ");
nama = System.console().readLine();
panjang = nama.length() + 4;
System.out.println("");
System.out.print("+");
for(int i = 0; i < panjang + 4; i++){
System.out.print("=");
}
System.out.println("+");
System.out.print("| ");
System.out.print("+");
...
Program Penjumlahan Dengan GUI
Sourc Code :
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.GridLayout;
public class Gui2 extends JFrame implements ActionListener{
private JButton btnHitung, btnClose;
private JLabel lblHasil, lblOpr;
private JTextField txt1, txt2;
public Gui2()...
Menghitung Sisi Miring, Luas, dan Segitiga Siku - Siku
Source Code :
import java.io.*;
public class IOQuiz {
public static void main(String[] args) throws Exception{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String input;
double a;
double t;
double sM;
double luas;
double kel;
System.out.println("\n\n");
System.out.println("| ===================================================================== |");
...
Program Diskon Barang
Source Code :
public class Jawaban{
public static void main (String [] args){
int kode, harga, diskon;
String jenis;
String sDiskon;
System.out.print("KODE : ");
kode = Integer.parseInt(System.console().readLine());
System.out.print("JENIS : ");
jenis = System.console().readLine();
System.out.print("HARGA : ");
harga = Integer.parseInt(System.console().readLine());
if(jenis.toUpperCase().equals("A"))
...
Bikin Program Nama Dengan GUI
Source Code :
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Container;
import java.awt.FlowLayout;
public class Jawaban1_GUI extends JFrame implements ActionListener
{
private JButton btnNim;
private JButton btnNama;
private JButton btnJurusan;
public Jawaban1_GUI()
{
setTitle("RESPONSI GUI");
...
Polymorphism
Source Code :
public class Polymorphism
{
public static void main(String [] args)
{
String nama [] =
{
"Hewan",
"Anjing",
"Bebek",
"Kucing"
};
Hewan [] hewan =
{
new Hewan(),
new Anjing(),
new Bebek(),
new Kucing()
};
for(int i = 0;...
Inheritance
Source Code :
import java.util.Scanner;
public class Inheritance {
public static void main(String [] args)
{
Paus paus = new Paus();
Cheetah cheetah = new Cheetah();
Sapi sapi = new Sapi();
Scanner in = new Scanner(System.in);
while(true)
{
System.out.println("\n___PILIH JENIS MAMALIA___");
System.out.println("[1]. IKAN PAUS");
System.out.println("[2]. CHEETAH");
...
Piramida
Source Code :
public class Piramid5
{
public static void main (String [] args)
{
int tinggi;
System.out.print("tinggi : ");
tinggi = Integer.parseInt(System.console().readLine());
for(int i = 0; i < tinggi; i++)
{
System.out.println("");
for(int j = 0; j < i; j++)
System.out.print(" ");
for(int j = tinggi; j > i; j--)
System.out.print("*");
for(int j = tinggi...
Mencari Luas Keliling Lingkaran
Source Code :
class LuasKelLingkaran{
public static void main (String [] xyz){
double r, kel, luas;
double PHI = 3.14;
String nim = "12.11.6156";
r = 50;
luas = PHI * Math.pow(r, 2);
kel = 2 * PHI * r;
System.out.println("\n\n\n\n\n\n\n\n\n\n");
System.out.println("|=========================================|");
System.out.println("| PROGRAM MENGHITUNG LUAS LINGKARAN...
Program Nilai Akhir
Source Code :
import javax.swing.JOptionPane;
public class NilaiAkhir {
public NilaiAkhir() {
}
public static void main (String [] args) throws NullPointerException, Exception{
final int MAX = 5;
int i = 0;
int hasil;
char huruf;
String ket;
int [] uas = new int [MAX];
int [] uts = new int [MAX];
int [] tugas = new int [MAX];
String...
Wednesday, June 5, 2013
Xari Roti
Source Code :
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import javax.swing.WindowConstants;
public class XariRoti
{
public static void main (String [] str)
{
InputStreamReader stream = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(stream);
int harga = 0;
int jml = 0, pilihan = 0, bayar;
String input;
System.out.println("\n\n\n|...
Menentukan Data Dengan Rumus Median
Source Code :
#include <iostream>
#include <cstdlib>
#include <iomanip>
#define max 10
using namespace std;
void swap(int *x, int *y)
{
int tmp;
if (*x<*y)
{
tmp = *x;
*x = *y;
*y = tmp;
}
}
void bublesort (int *array, int size)
{
for (int i=1;i<size;i++)
{
for(int j=size-1;j>=i;j--)
{
if(array[j] < array[j-1])
swap(&array[j],&array[j-1]);
}
}
}
void...
QUEUE
Source Code :
#include<iostream>
#include<cstdlib>
#define max 5
using namespace std;
struct QUEUE
{
int data[max];
int head;
int tail;
}antrian;
void init()
{
antrian.head=0;
antrian.tail=0;
}
bool kosong()
{
if (antrian.tail==0)
{
return true;
}
else
{
return false;
}
}
bool penuh()
{
if (antrian.tail==max)
{
return true;
}
else
{
return false;
}
}
void tampilData()
{
if...