import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class tipi extends tp{
superclass*/
String kecerahan;
int pilihan;
public tipi(){
super(); //keyword turunan
kecerahan="";
}
public tipi (String newChannel, String newVolume,
String newModern, String newHidup, String newMati, String newKecerahan ){
super (newChannel, newVolume, newModern, newHidup, newMati);
kecerahan=newKecerahan;
}
public void setKecerahan(String newKecerahan){
kecerahan=newKecerahan;
}
public void getKecerahan(){
// return kecerahan;
}
public String tuString(){
String str=
"CHANNEL :"+channel+"\n"+
"VOLUME :"+volume+"\n"+
"MODERN :"+modern+"\n"+
"HIDUP :"+hidup+"\n"+
"MATI :"+mati+"\n"+
"KECERAHAN:"+kecerahan+"\n";
return str;
}
public static void main(String[] args)throws IOException {
BufferedReader br= new BufferedReader (new InputStreamReader (System.in));
int a=1; //inisialisasi variabel
do{ //proses perulangan
System.out.println("\n\n== Pilihan : ==");
System.out.println("1 : Channel");
System.out.println("2 : Volume");
System.out.println("3 : Modern");
System.out.println("4 : Hidup");
System.out.println("5 : mati");
System.out.println("6 : Keluar");
System.out.print("\nPilihan Anda : ");
System.out.println("masukkan pilihan anda??");
int pilihan=Integer.parseInt(br.readLine());
switch(pilihan) {
case 1: //pilihan jika dimasukkan angka 1
System.out.println("masukkan channel yang anda inginkan???");
String channel=br.readLine(); //proses baca data yang diinputkan dalam keyboard
System.out.println("anda memilih channel:"+channel);
break;
case 2:
System.out.println("masukkan volume yang anda inginkan????");
String volume=br.readLine();
System.out.println("volume channel sekarang:"+volume);
break;
case 3:
System.out.println("masukkan modern yang anda inginkan???");
String modern=br.readLine();
System.out.println("anda sedang memilih:"+modern);
break;
case 4:
System.out.println("apakah tv hidup???");
String hidup=br.readLine();
System.out.println("sekarang keadaan tv:"+hidup);
break;
case 5:
System.out.println("apakah kondisi tv mati???");
String mati=br.readLine();
System.out.println("sekarang kondisi tv:"+mati);
break;
case 6 :
System.exit(0); //menandakan program selesai jika pilihan angka 6
break;
default:System.out.print("Pilihan Salah!");
}
}
while(a==1);
test();
}
}
Kuliah Pemrograman
Prasyarat untuk memenuhi mata kuliah Pemrograman Beroerientasi Objek (PBO)
Minggu, 14 Oktober 2012
CLASS UTAMA PROGRAM TV
package tv;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class TV {
public String channel;
public String volume;
public String modern;
public String hidup;
public String mati;
public TV(){//membuat intance baru
channel="";
volume="";
modern="";
hidup="";
mati="";
}
public TV (String newChannel, String newVolume, String newModern,
String newHidup, String newMati){
channel=newChannel;
volume=newVolume;
modern=newModern;
hidup=newHidup;
mati=newMati;
}
public void setChannel (String newChannel){
channel=newChannel;
}
public void setVolume (String newVolume){
volume=newVolume;
}
public void setModern (String newModern){
modern=newModern;
}
public void setHidup (String newHidup){
hidup=newHidup;
}
public void setMati (String newMati){
mati=newMati;
}
public String getChannel(){
return channel;
}
public String getVolume(){
return volume;
}
public String getModern(){
return modern;
}
public String getHidup(){
return hidup;
}
public String getMati(){
return mati;
}
public String tuString(){
String str=
"CHANNEL :"+channel+"\n"+
"VOLUME :"+volume+"\n"+
"MODERN :"+modern+"\n"+
"HIDUP :"+hidup+"\n"+
"MATI :"+mati+"\n";
return str;
}
static void test(){
//TURUNAN t=new TURUNAN (/*"SCTV","25","internet","hidup","mati"*/);
/*Scanner c=new Scanner(System.in);
System.out.println("masukkan channel yang anda inginkan"+t.getChannel());
channel=c.nextLine();
Scanner d=new Scanner(System.in);
System.out.println("masukkan volume yang anda inginkan"+t.getVolume());
volume=d.nextLine();
Scanner e=new Scanner(System.in);
System.out.println("masukkan channel yang anda inginkan"+t.getModern());
modern=e.nextLine();
Scanner f=new Scanner(System.in);
System.out.println("masukkan channel yang anda inginkan"+t.getHidup());
hidup=f.nextLine();
Scanner g=new Scanner(System.in);
System.out.println("masukkan channel yang anda inginkan"+t.getMati());
mati=g.nextLine();*/
/*System.out.println(t.getChannel());
System.out.println(t.getVolume());
System.out.println(t.getModern());
System.out.println(t.getHidup());
System.out.println(t.getMati());*/
}
public static void main(String[] args)throws IOException {
BufferedReader br= new BufferedReader (new InputStreamReader (System.in));
test();
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class TV {
public String channel;
public String volume;
public String modern;
public String hidup;
public String mati;
public TV(){//membuat intance baru
channel="";
volume="";
modern="";
hidup="";
mati="";
}
public TV (String newChannel, String newVolume, String newModern,
String newHidup, String newMati){
channel=newChannel;
volume=newVolume;
modern=newModern;
hidup=newHidup;
mati=newMati;
}
public void setChannel (String newChannel){
channel=newChannel;
}
public void setVolume (String newVolume){
volume=newVolume;
}
public void setModern (String newModern){
modern=newModern;
}
public void setHidup (String newHidup){
hidup=newHidup;
}
public void setMati (String newMati){
mati=newMati;
}
public String getChannel(){
return channel;
}
public String getVolume(){
return volume;
}
public String getModern(){
return modern;
}
public String getHidup(){
return hidup;
}
public String getMati(){
return mati;
}
public String tuString(){
String str=
"CHANNEL :"+channel+"\n"+
"VOLUME :"+volume+"\n"+
"MODERN :"+modern+"\n"+
"HIDUP :"+hidup+"\n"+
"MATI :"+mati+"\n";
return str;
}
static void test(){
//TURUNAN t=new TURUNAN (/*"SCTV","25","internet","hidup","mati"*/);
/*Scanner c=new Scanner(System.in);
System.out.println("masukkan channel yang anda inginkan"+t.getChannel());
channel=c.nextLine();
Scanner d=new Scanner(System.in);
System.out.println("masukkan volume yang anda inginkan"+t.getVolume());
volume=d.nextLine();
Scanner e=new Scanner(System.in);
System.out.println("masukkan channel yang anda inginkan"+t.getModern());
modern=e.nextLine();
Scanner f=new Scanner(System.in);
System.out.println("masukkan channel yang anda inginkan"+t.getHidup());
hidup=f.nextLine();
Scanner g=new Scanner(System.in);
System.out.println("masukkan channel yang anda inginkan"+t.getMati());
mati=g.nextLine();*/
/*System.out.println(t.getChannel());
System.out.println(t.getVolume());
System.out.println(t.getModern());
System.out.println(t.getHidup());
System.out.println(t.getMati());*/
}
public static void main(String[] args)throws IOException {
BufferedReader br= new BufferedReader (new InputStreamReader (System.in));
test();
}
}
Minggu, 30 September 2012
PEMROGRAMAN JAVA MENGHITUNG NILAI FAKTORIAL
PROGRAM :
package tugasmatrix;
/**
*
* @author Serly
*/
import java.io.*;
public class faktorisasi {
public static void main(String[] args)throws Exception{
InputStreamReader key = new InputStreamReader(System.in);
BufferedReader input = new BufferedReader(key);
String n;
int i,j,k=1;
System.out.print("Masukkan Nilai untuk di faktorialkan = ");
n=input.readLine();
j=Integer.parseInt(n);
System.out.print(j +" "+"!=");
for(i=j;i>=1;i--){
System.out.print(i);
if(i>1)
System.out.print("x");
k=k*i;
}
System.out.print("\n");
System.out.println(j+ " " +"!="+" "+k);
}
}
OUTPUT :
package tugasmatrix;
/**
*
* @author Serly
*/
import java.io.*;
public class faktorisasi {
public static void main(String[] args)throws Exception{
InputStreamReader key = new InputStreamReader(System.in);
BufferedReader input = new BufferedReader(key);
String n;
int i,j,k=1;
System.out.print("Masukkan Nilai untuk di faktorialkan = ");
n=input.readLine();
j=Integer.parseInt(n);
System.out.print(j +" "+"!=");
for(i=j;i>=1;i--){
System.out.print(i);
if(i>1)
System.out.print("x");
k=k*i;
}
System.out.print("\n");
System.out.println(j+ " " +"!="+" "+k);
}
}
OUTPUT :
PEMROGRAMAN JAVA PERKALIAN MATRIKS
PROGRAM :
package tugasmatrix;
/**
*
* @author Serly
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class matrixx {
static int[][] matrikA = new int[2][2];
static int[][] matrikB = new int[2][3];
static int[][] matrikHasil = new int[2][3];
static int ukuran;
public static void main(String[] args){
System.out.println("Masukkan Ukuran Matriks Yang Anda Inginkan : ");
ukuran = inputData();
bacaMatrix();
KalikanMatrix();
tulisHasil();
}
private static int inputData() {
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
String angkaInput = null;
try{
angkaInput = bfr.readLine();
}
catch(IOException e){
e.printStackTrace();
}
int Data=Integer.valueOf(angkaInput).intValue();
return Data;
}
private static void bacaMatrix() {
System.out.println("Masukkan Data Dari MatrikA :");
for(int i=0; i<ukuran; i++){
for(int j=0; j<ukuran; j++){
System.out.println("Matrik["+(i+1)+"]["+(j+1)+"]");
matrikA[i][j] = inputData();
}
}
System.out.println("Masukkan Data Dari MatrikB :");
for(int i=0; i<ukuran; i++){
for(int j=0; j<ukuran; j++){
System.out.println("Matrik["+(i+1)+"]["+(j+1)+"]");
matrikB[i][j] = inputData();
}
}
}
private static void KalikanMatrix() {
for(int i=0; i<ukuran; i++){
for(int j=0; j<ukuran; j++){
matrikHasil[i][j] = matrikA[i][j]*matrikB[i][j];
}
}
}
private static void tulisHasil() {
System.out.println("\n\nMatrik Dari Hasil Perkalian");
System.out.println("");
for(int i=0; i<ukuran; i++){
for(int j=0; j<ukuran; j++){
System.out.print(matrikHasil[i][j]+"\t");
}
System.out.println("");
}
}
}
OUTPUT :
package tugasmatrix;
/**
*
* @author Serly
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class matrixx {
static int[][] matrikA = new int[2][2];
static int[][] matrikB = new int[2][3];
static int[][] matrikHasil = new int[2][3];
static int ukuran;
public static void main(String[] args){
System.out.println("Masukkan Ukuran Matriks Yang Anda Inginkan : ");
ukuran = inputData();
bacaMatrix();
KalikanMatrix();
tulisHasil();
}
private static int inputData() {
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
String angkaInput = null;
try{
angkaInput = bfr.readLine();
}
catch(IOException e){
e.printStackTrace();
}
int Data=Integer.valueOf(angkaInput).intValue();
return Data;
}
private static void bacaMatrix() {
System.out.println("Masukkan Data Dari MatrikA :");
for(int i=0; i<ukuran; i++){
for(int j=0; j<ukuran; j++){
System.out.println("Matrik["+(i+1)+"]["+(j+1)+"]");
matrikA[i][j] = inputData();
}
}
System.out.println("Masukkan Data Dari MatrikB :");
for(int i=0; i<ukuran; i++){
for(int j=0; j<ukuran; j++){
System.out.println("Matrik["+(i+1)+"]["+(j+1)+"]");
matrikB[i][j] = inputData();
}
}
}
private static void KalikanMatrix() {
for(int i=0; i<ukuran; i++){
for(int j=0; j<ukuran; j++){
matrikHasil[i][j] = matrikA[i][j]*matrikB[i][j];
}
}
}
private static void tulisHasil() {
System.out.println("\n\nMatrik Dari Hasil Perkalian");
System.out.println("");
for(int i=0; i<ukuran; i++){
for(int j=0; j<ukuran; j++){
System.out.print(matrikHasil[i][j]+"\t");
}
System.out.println("");
}
}
}
OUTPUT :
Langganan:
Postingan (Atom)