Saturday, April 18, 2009
Thursday, March 16, 2006
highest
pahamkan and sesuaikan dengan program korang sendiri
public static void SortHighest(int marks[][],int bilpelajar)
{
String output="";
for(int i=(bilpelajar-1);i>=1;i--)
{
int currentmax=marks[0][1];
int currentmaxmetric=marks[0][0];
int currentmaxindex=0;
int currentmaxindexmetric=0;
for(int k=1;k<=i;k++)
{
if(currentmax {
currentmaxmetric=marks[k][0];
currentmax=marks[k][1];
currentmaxindex=k;
currentmaxindexmetric=k;
}
}
if(currentmaxindex!=i)
{
marks[currentmaxindex][1]=marks[i][1];
marks[currentmaxindexmetric][0]=marks[i][0];
marks[i][1]=currentmax;
marks[i][0]=currentmaxmetric;
}
}
for(int i=0;i {
output+="\n";
for(int j=0;j<2;j++)
{
output+=" "+marks[i][j];
}
}
JOptionPane.showMessageDialog(null,output, "4 - SORTED BY HIGHEST MARK",JOptionPane.INFORMATION_MESSAGE);
}
public static void SortHighest(int marks[][],int bilpelajar)
{
String output="";
for(int i=(bilpelajar-1);i>=1;i--)
{
int currentmax=marks[0][1];
int currentmaxmetric=marks[0][0];
int currentmaxindex=0;
int currentmaxindexmetric=0;
for(int k=1;k<=i;k++)
{
if(currentmax
currentmaxmetric=marks[k][0];
currentmax=marks[k][1];
currentmaxindex=k;
currentmaxindexmetric=k;
}
}
if(currentmaxindex!=i)
{
marks[currentmaxindex][1]=marks[i][1];
marks[currentmaxindexmetric][0]=marks[i][0];
marks[i][1]=currentmax;
marks[i][0]=currentmaxmetric;
}
}
for(int i=0;i
output+="\n";
for(int j=0;j<2;j++)
{
output+=" "+marks[i][j];
}
}
JOptionPane.showMessageDialog(null,output, "4 - SORTED BY HIGHEST MARK",JOptionPane.INFORMATION_MESSAGE);
}
coding sort highest
//pandai2la korang sesuaikan dengan ape nama method/array/dan yg sepatutnya..
jangan tak antar senin nanti
public static void SortHighest(int marks[][],int bilpelajar)
{
String output="";
for(int i=bilpelajar-1;i>=1;i--)
{
int currentmax=marks[0][1];
int currentmaxmetric=marks[0][0];
int currentmaxindex=0;
int currentmaxindexmetric=0;
for(int k=1;k<=i;k++) { if(currentmax {
currentmax=marks[k][1];
currentmaxmetric=marks[k][0];
currentmaxindex=k;
currentmaxindexmetric=k;
}
}
if(currentmaxindex!=i)
{
marks[currentmaxindex][1]=marks[i][1];
marks[currentmaxindexmetric][0]=marks[i][0];
marks[i][1]=currentmax;
marks[i][0]=currentmaxmetric;
}
}
//for(int i=0;i{
output+="\n";
for(int j=0;j<2;j++)
{
output+=" "+marks[i][j];
}
}
JOptionPane.showMessageDialog(null,output, "4 - SORTED BY HIGHEST MARK",JOptionPane.INFORMATION_MESSAGE); }
jangan tak antar senin nanti
public static void SortHighest(int marks[][],int bilpelajar)
{
String output="";
for(int i=bilpelajar-1;i>=1;i--)
{
int currentmax=marks[0][1];
int currentmaxmetric=marks[0][0];
int currentmaxindex=0;
int currentmaxindexmetric=0;
for(int k=1;k<=i;k++) { if(currentmax
currentmax=marks[k][1];
currentmaxmetric=marks[k][0];
currentmaxindex=k;
currentmaxindexmetric=k;
}
}
if(currentmaxindex!=i)
{
marks[currentmaxindex][1]=marks[i][1];
marks[currentmaxindexmetric][0]=marks[i][0];
marks[i][1]=currentmax;
marks[i][0]=currentmaxmetric;
}
}
//for(int i=0;i
output+="\n";
for(int j=0;j<2;j++)
{
output+=" "+marks[i][j];
}
}
JOptionPane.showMessageDialog(null,output, "4 - SORTED BY HIGHEST MARK",JOptionPane.INFORMATION_MESSAGE); }
gomen2..
gomennasai....saya tak sempat postkan lab 10. tunggulah. petang skit ye... tak bawak pendrivela...
Wednesday, March 01, 2006
JAWABAN LAB7
MAIN
import java.text.*;
public class lab_dip_7_soalan1
{
public static void main(String args[])
{
int bildress,bilpajama,bilshirt;
double total;
DecimalFormat p =new DecimalFormat("0.00");
lab_dip_7_soalan1_shirt myShirt=new lab_dip_7_soalan1_shirt);
lab_dip_7_soalan1_pajama myPajama=new lab_dip_7_soalan1_pajama();
lab_dip_7_soalan1_dress myDress=new lab_dip_7_soalan1_dress();
myShirt.beli();
myShirt.bayaran();
myShirt.papar();
myPajama.beli();
myPajama.bayaran();
myPajama.papar();
myDress.beli();
myDress.bayaran();
myDress.papar();
total=myShirt.bayaran+myPajama.bayaran+myDress.bayaran;
System.out.println("\n\nOVERALL\nTOTAL PRICE : RM "+p.format(total));
}
}
CLASS SHIRT
import java.text.*;
class lab_dip_7_soalan1_shirt
{
double hargashirt,diskaun, bayaran;
int bil;
DecimalFormat p =new DecimalFormat("0.00");
lab_dip_7_soalan1_shirt()
{
hargashirt=15.00;
}
void beli()
{
System.out.println("\nHow many Shirt to buy? ");
bil=MyInput.readInt();
}
void bayaran()
{
if(bil>10)
{
diskaun=0.50;
bayaran=(hargashirt*0.50)*bil;
}
else
bayaran=hargashirt*bil;
}
void papar()
{
System.out.println("Shirt Total Price: RM "+p.format(bayaran));
}
}
CLASS PAJAMA
import java.text.*;
class lab_dip_7_soalan1_pajama
{
double hargapajama,diskaun, bayaran;
int bil;
DecimalFormat p =new DecimalFormat("0.00");
lab_dip_7_soalan1_pajama()
{
hargapajama=18.90;
}
void beli()
{
System.out.println("\nHow many Pajama to buy? ");
bil=MyInput.readInt();
}
void bayaran()
{
if(bil>8)
{
diskaun=0.30;
bayaran=(hargapajama*0.70)*bil;
}
else
bayaran=hargapajama*bil;
}
void papar()
{
System.out.println("Pajama Total Price: RM "+p.format(bayaran));
}
}
CLASS DRESS
import java.text.*;
class lab_dip_7_soalan1_dress
{
double hargadress,diskaun,bayaran;
int bil;
DecimalFormat p =new DecimalFormat("0.00");
lab_dip_7_soalan1_dress()
{
hargadress=29.99;
}
void beli()
{
System.out.println("\nHow many dress to buy? ");
bil=MyInput.readInt();
}
void bayaran()
{
if(bil>5)
{
diskaun=0.25;
bayaran=(hargadress*0.75)*bil;
}
else
bayaran=hargadress*bil;
}
void papar()
{
System.out.println("Dress Total Price: RM "+p.format(bayaran));
}
}
import java.text.*;
public class lab_dip_7_soalan1
{
public static void main(String args[])
{
int bildress,bilpajama,bilshirt;
double total;
DecimalFormat p =new DecimalFormat("0.00");
lab_dip_7_soalan1_shirt myShirt=new lab_dip_7_soalan1_shirt);
lab_dip_7_soalan1_pajama myPajama=new lab_dip_7_soalan1_pajama();
lab_dip_7_soalan1_dress myDress=new lab_dip_7_soalan1_dress();
myShirt.beli();
myShirt.bayaran();
myShirt.papar();
myPajama.beli();
myPajama.bayaran();
myPajama.papar();
myDress.beli();
myDress.bayaran();
myDress.papar();
total=myShirt.bayaran+myPajama.bayaran+myDress.bayaran;
System.out.println("\n\nOVERALL\nTOTAL PRICE : RM "+p.format(total));
}
}
CLASS SHIRT
import java.text.*;
class lab_dip_7_soalan1_shirt
{
double hargashirt,diskaun, bayaran;
int bil;
DecimalFormat p =new DecimalFormat("0.00");
lab_dip_7_soalan1_shirt()
{
hargashirt=15.00;
}
void beli()
{
System.out.println("\nHow many Shirt to buy? ");
bil=MyInput.readInt();
}
void bayaran()
{
if(bil>10)
{
diskaun=0.50;
bayaran=(hargashirt*0.50)*bil;
}
else
bayaran=hargashirt*bil;
}
void papar()
{
System.out.println("Shirt Total Price: RM "+p.format(bayaran));
}
}
CLASS PAJAMA
import java.text.*;
class lab_dip_7_soalan1_pajama
{
double hargapajama,diskaun, bayaran;
int bil;
DecimalFormat p =new DecimalFormat("0.00");
lab_dip_7_soalan1_pajama()
{
hargapajama=18.90;
}
void beli()
{
System.out.println("\nHow many Pajama to buy? ");
bil=MyInput.readInt();
}
void bayaran()
{
if(bil>8)
{
diskaun=0.30;
bayaran=(hargapajama*0.70)*bil;
}
else
bayaran=hargapajama*bil;
}
void papar()
{
System.out.println("Pajama Total Price: RM "+p.format(bayaran));
}
}
CLASS DRESS
import java.text.*;
class lab_dip_7_soalan1_dress
{
double hargadress,diskaun,bayaran;
int bil;
DecimalFormat p =new DecimalFormat("0.00");
lab_dip_7_soalan1_dress()
{
hargadress=29.99;
}
void beli()
{
System.out.println("\nHow many dress to buy? ");
bil=MyInput.readInt();
}
void bayaran()
{
if(bil>5)
{
diskaun=0.25;
bayaran=(hargadress*0.75)*bil;
}
else
bayaran=hargadress*bil;
}
void papar()
{
System.out.println("Dress Total Price: RM "+p.format(bayaran));
}
}
JAWABAN LAB8
public class lab_dip_8_soalan1
{
public static void main(String args[])
{
String g1=new String("Morning People");
String g2=new String("I Love Milo");
//yang lebih panjang di uppercasekan
if((g1.length())>(g2.length()))
{
System.out.println("The longer word : "+g1.toUpperCase());
System.out.println("The shorter word : "+g2.toLowerCase());
}
else
{
System.out.println("The longer word : "+g2.toUpperCase());
System.out.println("The shorter word : "+g1.toLowerCase());
}
String g3,g4,g5,g6,g7;
g3=g1.substring(0,8); //keluarkan Morning
g4=g2.substring(0,7)+g3; //jadi ayat :I Love Morning
System.out.println(); System.out.println("1- "+g4);
g5=g3=g1.substring(8,14); //keluarkan People
g6=g5+g2.substring(1,11); //jadi ayat:People Love Milo
System.out.println("2- "+g6);
g7="Good "+g1+"!!!"; System.out.println("3- "+g7);
System.out.print("\n");
}
}
{
public static void main(String args[])
{
String g1=new String("Morning People");
String g2=new String("I Love Milo");
//yang lebih panjang di uppercasekan
if((g1.length())>(g2.length()))
{
System.out.println("The longer word : "+g1.toUpperCase());
System.out.println("The shorter word : "+g2.toLowerCase());
}
else
{
System.out.println("The longer word : "+g2.toUpperCase());
System.out.println("The shorter word : "+g1.toLowerCase());
}
String g3,g4,g5,g6,g7;
g3=g1.substring(0,8); //keluarkan Morning
g4=g2.substring(0,7)+g3; //jadi ayat :I Love Morning
System.out.println(); System.out.println("1- "+g4);
g5=g3=g1.substring(8,14); //keluarkan People
g6=g5+g2.substring(1,11); //jadi ayat:People Love Milo
System.out.println("2- "+g6);
g7="Good "+g1+"!!!"; System.out.println("3- "+g7);
System.out.print("\n");
}
}
Friday, February 17, 2006
JAWABAN LAB6
CLASS CAR //tapi sayapunya ni namanya :lab_dip_6_car
import javax.swing.JOptionPane;
class lab_dip_6_car
{
String make;
String type;
double cc;
String color;
lab_dip_6_car(String carmake, String cartype,double num, String kaler)
{
make=carmake;
type=cartype;
cc=num;
color=kaler;
}
void print()
{
System.out.println("Make : "+make);
System.out.println("Type : "+type);
System.out.println("CC : "+cc);
System.out.println("Colour : "+color);
System.out.println();
}
}
THE MAIN CLASS
import javax.swing.JOptionPane;
public class lab_dip_6_soalan1
{
public static void main(String args[])
{
lab_dip_6_car mycar=new lab_dip_6_car("Perodua","Kelisa",1.7,"Red");
mycar.print();
System.exit(0);
}
}
import javax.swing.JOptionPane;
class lab_dip_6_car
{
String make;
String type;
double cc;
String color;
lab_dip_6_car(String carmake, String cartype,double num, String kaler)
{
make=carmake;
type=cartype;
cc=num;
color=kaler;
}
void print()
{
System.out.println("Make : "+make);
System.out.println("Type : "+type);
System.out.println("CC : "+cc);
System.out.println("Colour : "+color);
System.out.println();
}
}
THE MAIN CLASS
import javax.swing.JOptionPane;
public class lab_dip_6_soalan1
{
public static void main(String args[])
{
lab_dip_6_car mycar=new lab_dip_6_car("Perodua","Kelisa",1.7,"Red");
mycar.print();
System.exit(0);
}
}
Tuesday, February 07, 2006
acres
korang nakpi mana? acres? hecters? macres? (^,^) o...sesapa yg ada namanya tu, jalan bebaik.
ok chow, selamat menyambut Thaipusam kepada sesapa yg menyambutnye.
ok chow, selamat menyambut Thaipusam kepada sesapa yg menyambutnye.
JAWABAN LAB5
Soalan1
import javax.swing.*;
public class lab_dip_5_soalan1
{
public static void main(String args[])
{
int num;
String hasilproses;
num=input();
hasilproses=process( num);
output(num,hasilproses);
System.exit(0);
}
public static int input()
{
int no;
no=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter an integer : "));
return no;
}
public static String process(int no)
{
int baki;
String hasil;
baki=no%2;
if(baki==0)
hasil="even";
else
hasil="odd";
return hasil;
}
public static void output(int no,String hasil)
{
JOptionPane.showMessageDialog(null,no+" is an "+hasil+" integer", "Output",JOptionPane.INFORMATION_MESSAGE);
}
}
Soalan2
import javax.swing.*;
public class lab_dip_5_soalan2
{
public static void main(String args[])
{
double weight, height;
String result;
weight=inputWeight();
height=inputHeight();
result=analyze( height, weight);
output( height, weight, result);
System.exit(0);
}
public static double inputWeight()
{
double weight;
weight=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter weight : "));
return weight;
}
public static double inputHeight()
{
double height;
height=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter height : "));
return height;
}
public static String analyze(double height,double weight)
{
double bmi=weight/((height/100)*(height/100));
String result;
if (bmi<=25)
result="Normal";
else if(bmi>25&&bmi<30)
result="Fat";
else
result="Obese";
return result;
}
public static void output(double height,double weight,String result)
{
JOptionPane.showMessageDialog(null,"Weight : "+weight+"\nHeight : "+height+"\n\nFrom my BMI
>> "+result,"Output",JOptionPane.INFORMATION_MESSAGE);
}
}
import javax.swing.*;
public class lab_dip_5_soalan1
{
public static void main(String args[])
{
int num;
String hasilproses;
num=input();
hasilproses=process( num);
output(num,hasilproses);
System.exit(0);
}
public static int input()
{
int no;
no=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter an integer : "));
return no;
}
public static String process(int no)
{
int baki;
String hasil;
baki=no%2;
if(baki==0)
hasil="even";
else
hasil="odd";
return hasil;
}
public static void output(int no,String hasil)
{
JOptionPane.showMessageDialog(null,no+" is an "+hasil+" integer", "Output",JOptionPane.INFORMATION_MESSAGE);
}
}
Soalan2
import javax.swing.*;
public class lab_dip_5_soalan2
{
public static void main(String args[])
{
double weight, height;
String result;
weight=inputWeight();
height=inputHeight();
result=analyze( height, weight);
output( height, weight, result);
System.exit(0);
}
public static double inputWeight()
{
double weight;
weight=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter weight : "));
return weight;
}
public static double inputHeight()
{
double height;
height=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter height : "));
return height;
}
public static String analyze(double height,double weight)
{
double bmi=weight/((height/100)*(height/100));
String result;
if (bmi<=25)
result="Normal";
else if(bmi>25&&bmi<30)
result="Fat";
else
result="Obese";
return result;
}
public static void output(double height,double weight,String result)
{
JOptionPane.showMessageDialog(null,"Weight : "+weight+"\nHeight : "+height+"\n\nFrom my BMI
>> "+result,"Output",JOptionPane.INFORMATION_MESSAGE);
}
}
Thursday, February 02, 2006
testing power for the 1st time
assalamualaikum ya korang....
good luck 4 ur test a...
pastikan betul2 paham pasal suma loop statement yang ada:if/while/do-while/switch/for
tgk syntax betul2...pastikan paham aper yg ditulis....
gambatte!!! p(^o^)q
chow...
good luck 4 ur test a...
pastikan betul2 paham pasal suma loop statement yang ada:if/while/do-while/switch/for
tgk syntax betul2...pastikan paham aper yg ditulis....
gambatte!!! p(^o^)q
chow...
JAWABAN LAB4
soalan1
import javax.swing.*;
import java.text.*;
public class lab_dip_4_soalan1
{
public static void main(String args[])
{
int input;
String output="";
input=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter a value : "));
while(input!=0)
{
output+=input+"\t ";
input--;
}
JOptionPane.showMessageDialog(null,output,"USING WHILE",JOptionPane.INFORMATION_MESSAGE); System.exit(0);
}
}
soalan2
import javax.swing.*;
import java.text.*;
public class lab_dip_4_soalan2
{
public static void main(String args[])
{
int sum=0;
int input;
do
{
input=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter an integer value\nProgram exit if input is 0\n"));
sum+=input;
}while(input!=0);
JOptionPane.showMessageDialog(null,"Sum : "+sum,"USING DO-WHILE",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
soalan3
import javax.swing.*;
import java.text.*;
public class lab_dip_4_soalan3
{
public static void main(String args[])
{
int item;
String deli;
int bil_item;
double item_price,price;
DecimalFormat p=new DecimalFormat("0.00");
item=Integer.parseInt(JOptionPane.showInputDialog(null,"My Favourite Bakery\n\nCODE BREAD\n210 Mexican Bun\n122 Chocolate Donut\n768 Sausage Bun\n234 Cheese Stick \n\n[Enter Code] \nI want to buy :"));
bil_item=Integer.parseInt(JOptionPane.showInputDialog(null,"How many do you want to buy?"));
switch(item)
{
case 210: item_price=1.90;
deli="Mexican Bun";
break;
case 122: item_price=1.80;
deli="Chocolate Donut";
break;
case 768: item_price=1.50;
deli="Sausage Bun";
break;
case 234: item_price=1.00;
deli="Cheese Stick";
break;
default: item_price=0.00;
bil_item=0;
deli="No such thing at our bakery...";
}
price=item_price*bil_item;
JOptionPane.showMessageDialog(null,deli+"\n\nBuy = "+bil_item+"\n\nPrice = RM "+p.format(price),"USING SWITCH STATEMENT",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
import javax.swing.*;
import java.text.*;
public class lab_dip_4_soalan1
{
public static void main(String args[])
{
int input;
String output="";
input=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter a value : "));
while(input!=0)
{
output+=input+"\t ";
input--;
}
JOptionPane.showMessageDialog(null,output,"USING WHILE",JOptionPane.INFORMATION_MESSAGE); System.exit(0);
}
}
soalan2
import javax.swing.*;
import java.text.*;
public class lab_dip_4_soalan2
{
public static void main(String args[])
{
int sum=0;
int input;
do
{
input=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter an integer value\nProgram exit if input is 0\n"));
sum+=input;
}while(input!=0);
JOptionPane.showMessageDialog(null,"Sum : "+sum,"USING DO-WHILE",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
soalan3
import javax.swing.*;
import java.text.*;
public class lab_dip_4_soalan3
{
public static void main(String args[])
{
int item;
String deli;
int bil_item;
double item_price,price;
DecimalFormat p=new DecimalFormat("0.00");
item=Integer.parseInt(JOptionPane.showInputDialog(null,"My Favourite Bakery\n\nCODE BREAD\n210 Mexican Bun\n122 Chocolate Donut\n768 Sausage Bun\n234 Cheese Stick \n\n[Enter Code] \nI want to buy :"));
bil_item=Integer.parseInt(JOptionPane.showInputDialog(null,"How many do you want to buy?"));
switch(item)
{
case 210: item_price=1.90;
deli="Mexican Bun";
break;
case 122: item_price=1.80;
deli="Chocolate Donut";
break;
case 768: item_price=1.50;
deli="Sausage Bun";
break;
case 234: item_price=1.00;
deli="Cheese Stick";
break;
default: item_price=0.00;
bil_item=0;
deli="No such thing at our bakery...";
}
price=item_price*bil_item;
JOptionPane.showMessageDialog(null,deli+"\n\nBuy = "+bil_item+"\n\nPrice = RM "+p.format(price),"USING SWITCH STATEMENT",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
JAWABAN LAB3
satu soalan sahaja....
import javax.swing.*;
public class lab_dip_3_soalan1
{
public static void main(String args[])
{
String name;
double income_tax,kwsp,travel_allowance,grosspay,salary;
int employee_id,days_work;
name=JOptionPane.showInputDialog(null,"Enter your name:","INPUT NAME",JOptionPane.QUESTION_MESSAGE);
employee_id=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter your employee identification number :","INPUT ID",JOptionPane.QUESTION_MESSAGE));
days_work=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter number of days work :","INPUT DAYS WORKED",JOptionPane.QUESTION_MESSAGE));
grosspay=days_work*200;
travel_allowance=0.04*grosspay;
income_tax=0.03*grosspay;
kwsp=0.02*grosspay;
salary=grosspay+travel_allowance-income_tax-kwsp;
JOptionPane.showMessageDialog(null,"Employee ID : "+employee_id+"\nEmployee name : "+name+"\n\nGrosspay = RM "+grosspay+"\nTravel allowance = RM "+travel_allowance+"\nIncome tax = RM "+income_tax+"\nKWSP = RM "+kwsp+"\n\nSalary = RM "+salary,"RESULT",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
import javax.swing.*;
public class lab_dip_3_soalan1
{
public static void main(String args[])
{
String name;
double income_tax,kwsp,travel_allowance,grosspay,salary;
int employee_id,days_work;
name=JOptionPane.showInputDialog(null,"Enter your name:","INPUT NAME",JOptionPane.QUESTION_MESSAGE);
employee_id=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter your employee identification number :","INPUT ID",JOptionPane.QUESTION_MESSAGE));
days_work=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter number of days work :","INPUT DAYS WORKED",JOptionPane.QUESTION_MESSAGE));
grosspay=days_work*200;
travel_allowance=0.04*grosspay;
income_tax=0.03*grosspay;
kwsp=0.02*grosspay;
salary=grosspay+travel_allowance-income_tax-kwsp;
JOptionPane.showMessageDialog(null,"Employee ID : "+employee_id+"\nEmployee name : "+name+"\n\nGrosspay = RM "+grosspay+"\nTravel allowance = RM "+travel_allowance+"\nIncome tax = RM "+income_tax+"\nKWSP = RM "+kwsp+"\n\nSalary = RM "+salary,"RESULT",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
JAWABAN LAB2
soalan1
// JAWAPAN MENGGUNAKAN S.O.P
import java.text.*;
public class lab_dip_2_soalan1
{
public static void main(String args[])
{
double Celcius; double Fahrenheit;
System.out.print("Celcius =");
Celcius=MyInput.readDouble();
Fahrenheit=((Celcius*9)/5)+32;
System.out.println("Fahrenheit ="+Fahrenheit);
}
}
//JAWAPAN MENGGUNAKAN J.O.P
import javax.swing.JOptionPane;
public class lab_dip_2_soalan1
{
public static void main(String args[])
{
double Celcius; double Fahrenheit;
Celcius=Double.parseDouble(JOptionPane.showInputDialog(null,"Celcius =","INPUT CELCIUS",JOptionPane.QUESTION_MESSAGE));
Fahrenheit=((Celcius*9)/5)+32;
JOptionPane.showMessageDialog(null,"Fahrenheit ="+Fahrenheit,"THE OUTPUT",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
soalan2
//MENGGUNAKAN S.O.P
import java.text.*;
public class lab_dip_2_soalan2
{
public static void main(String args[])
{
double a; double b; double sum,diff,pro,div;
System.out.print("Enter the first value :");
a=MyInput.readDouble();
System.out.print("Enter the second value :");
b=MyInput.readDouble();
sum=a+b;
diff=a-b;
pro=a*b;
div=a/b;
System.out.println("Sum ="+sum+"\n"+"Difference ="+diff+"\n"+"Product ="+pro+"\n"+"Division ="+div);
}
}
//MENGGUNAKAN J.O.P
import javax.swing.JOptionPane;
public class lab_dip_2_soalan2
{
public static void main(String args[])
{
double a;
double b;
double sum,diff,pro,div;
String output="";
a=Double.parseDouble(JOptionPane.showInputDialog(null,"First Value =","INPUT VALUE",JOptionPane.QUESTION_MESSAGE));
b=Double.parseDouble(JOptionPane.showInputDialog(null,"First Value =","INPUT VALUE",JOptionPane.QUESTION_MESSAGE));
sum=a+b;
diff=a-b;
pro=a*b;
div=a/b;
output+="Sum ="+sum+"\n"+"Difference ="+diff+"\n"+"Product ="+pro+"\n"+"Division ="+div;
JOptionPane.showMessageDialog(null,output,"RESULT",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
// JAWAPAN MENGGUNAKAN S.O.P
import java.text.*;
public class lab_dip_2_soalan1
{
public static void main(String args[])
{
double Celcius; double Fahrenheit;
System.out.print("Celcius =");
Celcius=MyInput.readDouble();
Fahrenheit=((Celcius*9)/5)+32;
System.out.println("Fahrenheit ="+Fahrenheit);
}
}
//JAWAPAN MENGGUNAKAN J.O.P
import javax.swing.JOptionPane;
public class lab_dip_2_soalan1
{
public static void main(String args[])
{
double Celcius; double Fahrenheit;
Celcius=Double.parseDouble(JOptionPane.showInputDialog(null,"Celcius =","INPUT CELCIUS",JOptionPane.QUESTION_MESSAGE));
Fahrenheit=((Celcius*9)/5)+32;
JOptionPane.showMessageDialog(null,"Fahrenheit ="+Fahrenheit,"THE OUTPUT",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
soalan2
//MENGGUNAKAN S.O.P
import java.text.*;
public class lab_dip_2_soalan2
{
public static void main(String args[])
{
double a; double b; double sum,diff,pro,div;
System.out.print("Enter the first value :");
a=MyInput.readDouble();
System.out.print("Enter the second value :");
b=MyInput.readDouble();
sum=a+b;
diff=a-b;
pro=a*b;
div=a/b;
System.out.println("Sum ="+sum+"\n"+"Difference ="+diff+"\n"+"Product ="+pro+"\n"+"Division ="+div);
}
}
//MENGGUNAKAN J.O.P
import javax.swing.JOptionPane;
public class lab_dip_2_soalan2
{
public static void main(String args[])
{
double a;
double b;
double sum,diff,pro,div;
String output="";
a=Double.parseDouble(JOptionPane.showInputDialog(null,"First Value =","INPUT VALUE",JOptionPane.QUESTION_MESSAGE));
b=Double.parseDouble(JOptionPane.showInputDialog(null,"First Value =","INPUT VALUE",JOptionPane.QUESTION_MESSAGE));
sum=a+b;
diff=a-b;
pro=a*b;
div=a/b;
output+="Sum ="+sum+"\n"+"Difference ="+diff+"\n"+"Product ="+pro+"\n"+"Division ="+div;
JOptionPane.showMessageDialog(null,output,"RESULT",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
JAWABAN LAB1
jawapan untuk lab1, specially made by me (^,^)
soalan1
public class lab_dip_1_soalan1
{
public static void main(String args[])
{
System.out.println(" * * * * * * * * * * * * * *");
System.out.println(" * *");
System.out.println(" * *");
System.out.println(" * *");
System.out.println(" * Welcome to JAVA!!! *");
System.out.println(" * *");
System.out.println(" * *");
System.out.println(" * *");
System.out.println(" * * * * * * * * * * * * * *");
System.out.println();
}
}
soalan2
import javax.swing.JOptionPane;
public class lab_dip_1_soalan2
{
public static void main(String args[])
{
JOptionPane.showMessageDialog(null,"Fantastique J A V A !!!",
"Lab 1.2 Using JOptionPane",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
soalan3
import javax.swing.JOptionPane;
public class lab_dip_1_soalan3
{
public static void main(String args[])
{
JOptionPane.showMessageDialog(null,"112233\nMuhammad Arif",
"MAKLUMAT DIRI",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
soalan1
public class lab_dip_1_soalan1
{
public static void main(String args[])
{
System.out.println(" * * * * * * * * * * * * * *");
System.out.println(" * *");
System.out.println(" * *");
System.out.println(" * *");
System.out.println(" * Welcome to JAVA!!! *");
System.out.println(" * *");
System.out.println(" * *");
System.out.println(" * *");
System.out.println(" * * * * * * * * * * * * * *");
System.out.println();
}
}
soalan2
import javax.swing.JOptionPane;
public class lab_dip_1_soalan2
{
public static void main(String args[])
{
JOptionPane.showMessageDialog(null,"Fantastique J A V A !!!",
"Lab 1.2 Using JOptionPane",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
soalan3
import javax.swing.JOptionPane;
public class lab_dip_1_soalan3
{
public static void main(String args[])
{
JOptionPane.showMessageDialog(null,"112233\nMuhammad Arif",
"MAKLUMAT DIRI",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
Tuesday, January 24, 2006
Subscribe to:
Posts (Atom)