Aku dapat soal Tipe B.
Kalo gak salah soalnya seperti ini deh :
- Buatlah sebuah program untuk konversi dari pound ke Kg(1 pound = 0.454)
- Buatlah program untuk informasi bilangan, misalnya negatif, positif, dan nol.(dengan menggunakan jendela inputan, beserta judul jendelanya menggunakan nama anda)
- Buatlah program yang digunakan konversi dari celcius ke Fahrenheit.(dengan menggunakan jendela inputan, beserta judul jendelanya menggunakan nama anda)
- Buatlah program yang digunakan untuk menerima inputan berupa kode bulan kemudian menampilkan bulan beserta jumlah harinya. buatlah dengan if-else dan switch(dengan menggunakan jendela inputan, beserta judul jendelanya menggunakan nama anda)
no 1 :
Program KonvertpoundToKg
public class KonvertpoundToKg{
public static void main(String args[]){
double pound=5;
double KG=0.454;
double Hasil;
Hasil=pound*KG;
System.out.println("Hasil Konversi dari "+pound+" pound adalah "+Hasil+" Kg");
}
}
output
no 2 :
import javax.swing.JOptionPane;Output :
public class InformasiBil{
public static void main(String args[]){
String input=" ";
input=JOptionPane.showInputDialog(null,"Masukkan Bilangan : ","Muhammad Alvin Syahdana",JOptionPane.QUESTION_MESSAGE);
double bil=Double.parseDouble(input);
if(bil>0){
JOptionPane.showMessageDialog(null,"Bilangan Positif","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);
}
else if(bil<0){
JOptionPane.showMessageDialog(null,"Bilangan Negatif","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);
}
else{
JOptionPane.showMessageDialog(null,"Bilangan Nol","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);
}
}
}
no 3 :
import javax.swing.JOptionPane;Output :
public class KonvertCelciusFahrenheit{
public static void main(String args[]){
String input=" ";
input=JOptionPane.showInputDialog(null,"Masukkan Suhu (Celcius) : ","Muhammad Alvin Syahdana",JOptionPane.QUESTION_MESSAGE);
double Celcius=Double.parseDouble(input);
double Fahrenheit;
Fahrenheit = (9/5)*(Celcius+32);
JOptionPane.showMessageDialog(null,"Konversi dari "+Celcius+" Celcius = "+Fahrenheit+ " Fahrenheit","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);
}
}
no 4 if - else :
import javax.swing.JOptionPane;Output :
public class KodeBlnIfElse{
public static void main(String args[]){
String input=" ";
input=JOptionPane.showInputDialog(null,"Masukkan Kode Bulan: ","Muhammad Alvin Syahdana",JOptionPane.QUESTION_MESSAGE);
int bulan=Integer.parseInt(input);
if(bulan==1){
JOptionPane.showMessageDialog(null,"Bulan Januari = 31 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);
}
else if(bulan==2){
JOptionPane.showMessageDialog(null,"Bulan Pebruari = 28 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);
}
else if(bulan==3){
JOptionPane.showMessageDialog(null,"Bulan Maret = 31 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);
}
else if(bulan==4){
JOptionPane.showMessageDialog(null,"Bulan April = 30 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);
}
else if(bulan==5){
JOptionPane.showMessageDialog(null,"Bulan Mei = 31 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);
}
else if(bulan==6){
JOptionPane.showMessageDialog(null,"Bulan Juni = 30 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);
}
else if(bulan==7){
JOptionPane.showMessageDialog(null,"Bulan Juli = 31 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);
}
else if(bulan==8){
JOptionPane.showMessageDialog(null,"Bulan Agustus = 31 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);
}
else if(bulan==9){
JOptionPane.showMessageDialog(null,"Bulan September = 30 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);
}
else if(bulan==10){
JOptionPane.showMessageDialog(null,"Bulan Oktober = 31 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);
}
else if(bulan==11){
JOptionPane.showMessageDialog(null,"Bulan November = 30 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);
}
else if(bulan==12){
JOptionPane.showMessageDialog(null,"Bulan Desember = 31 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);
}
else{
JOptionPane.showMessageDialog(null,"Input Salah","Muhammad Alvin Syahdana",JOptionPane.ERROR_MESSAGE);
}
}
}
no 4 - switch :
import javax.swing.JOptionPane;Output :
public class KodeBlnSwitch{
public static void main(String args[]){
String input=" ";
input=JOptionPane.showInputDialog(null,"Masukkan Kode Bulan: ","Muhammad Alvin Syahdana",JOptionPane.QUESTION_MESSAGE);
int bulan=Integer.parseInt(input);
switch(bulan){
case 1 : JOptionPane.showMessageDialog(null,"Bulan Januari = 31 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);break;
case 2 : JOptionPane.showMessageDialog(null,"Bulan Pebruari = 28 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);break;
case 3 : JOptionPane.showMessageDialog(null,"Bulan Maret = 31 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);break;
case 4 : JOptionPane.showMessageDialog(null,"Bulan April = 30 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);break;
case 5 : JOptionPane.showMessageDialog(null,"Bulan Mei = 31 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);break;
case 6 : JOptionPane.showMessageDialog(null,"Bulan Juni = 30 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);break;
case 7 : JOptionPane.showMessageDialog(null,"Bulan Juli = 31 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);break;
case 8 : JOptionPane.showMessageDialog(null,"Bulan Agustus = 31 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);break;
case 9 : JOptionPane.showMessageDialog(null,"Bulan September = 30 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);break;
case 10 : JOptionPane.showMessageDialog(null,"Bulan Oktober = 31 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);break;
case 11 : JOptionPane.showMessageDialog(null,"Bulan November = 30 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);break;
case 12 : JOptionPane.showMessageDialog(null,"Bulan Desember = 31 Hari","Muhammad Alvin Syahdana",JOptionPane.WARNING_MESSAGE);break;
default : JOptionPane.showMessageDialog(null,"Maaf, Input yang anda inputkan Salah !!!","Muhammad Alvin Syahdana",JOptionPane.ERROR_MESSAGE);
}
}
}
fuih, selesai deh soalnya, tinggal dikumpul....... ALhamdulillah.......
---SELESAI---
Tidak ada komentar:
Posting Komentar