Rabu, 26 Juni 2013

Tugas Program Pbo Bu SuryaNingrum

import java.util.Scanner;
import javax.swing.*;
class pbo1
{
            int a,b;
            Scanner input = new Scanner(System.in);
           
            public void inputnilai()
            {
                        a = Integer.parseInt(JOptionPane.showInputDialog("Masukan Nilai A :"));
                b = Integer.parseInt(JOptionPane.showInputDialog("Masukan Nilai B :"));
            }
           
            public void string()
            {
                        String karakter = JOptionPane.showInputDialog ("Masukkan Karakter Anda : ");
                       JOptionPane.showMessageDialog(null,"Hasil String Adalah : \n " +karakter.toUpperCase() + "\n " +karakter.toLowerCase());
            }
                       

            public void kalkulator()
            {
                        int c;
                        while(true)
                        {
                                    int pil = Integer.parseInt(JOptionPane.showInputDialog("^^^^^^^^^^^^^^^^^^^^^\n^   Program Kalkulator   ^\n^^^^^^^^^^^^^^^^^^^^^\n^ 1.Penjumlahan              ^\n^ 2.Pengurangan              ^\n^ 3.Perkalian                     ^\n^ 4.Pembagian                 ^\n^ 5.Keluar                          ^\n^^^^^^^^^^^^^^^^^^^^^\n Masukkan pilihan mu : "));
                                    switch(pil)
                                    {
                                                case 1:
                                                {
                                                            inputnilai();
                                                            c = a + b;
                                                           JOptionPane.showMessageDialog(null,"Hasil Penjumlahan :"+c);
                                                            kalkulator();
                                                            continue;
                                                }
                                               
                                                case 2:
                                                {
                                                            inputnilai();
                                                            c = a - b;
                                                           JOptionPane.showMessageDialog(null,"Hasil Pengurangan :"+c);
                                                            kalkulator();
                                                            continue;
                                                }
                                               
                                                case 3:
                                                {
                                                            inputnilai();
                                                            c = a * b;
                                                           JOptionPane.showMessageDialog(null,"Hasil Perkalian :"+c);
                                                            kalkulator();
                                                            continue;
                                                }
                                                case 4:
                                                {
                                                            inputnilai();
                                                            c = a / b;
                                                           JOptionPane.showMessageDialog(null,"Hasil Pembagian :"+c);
                                                            kalkulator();
                                                            continue;
                                                }
                                                case 5:
                                                {
                                                           JOptionPane.showMessageDialog(null,"BYE - BYE !!!!!!!!!!!!");
                                                            break;
                                                }
                                               
                                                default:
                                                {
                                                           System.out.println("Tolong Pilih Menunya !!!");
                                                            continue;
                                                }
                                    }
                                    break;
                        }
            }
}

class pbo2 extends pbo1
{
            Scanner input = new Scanner(System.in);
            public void menu()
            {
                        while(true)
                        {
                                    int pil = Integer.parseInt(JOptionPane.showInputDialog("^+^+^+^+^+^+^+^+^+^+^+^+^\n^            MENU UTAMA               ^\n^+^+^+^+^+^+^+^+^+^+^+^+^\n^ 1.Program String                    ^\n^ 2.Program Kalkulator            ^\n^ 3.Keluar                                    ^\n^+^+^+^+^+^+^+^+^+^+^+^+^\n Masukkan pilihan mu : "));
                                    pbo1 induk = new pbo1();
                                    switch(pil)
                                    {
                                                case 1:
                                                {
                                                            induk.string();
                                                            menu();
                                                            continue;
                                                }
                                               
                                                case 2:
                                                {
                                                           induk.kalkulator();
                                                            menu();
                                                            continue;
                                                }
                                               
                                                case 3:
                                                {
                                                           JOptionPane.showMessageDialog(null,"BYE - BYE !!!!!!!!!!!!");
                                                            System.exit(5);
                                                            break;
                                                }
                                               
                                                default:
                                                {
                                                           JOptionPane.showMessageDialog(null,"Tolong Pilih Menunya!!!!!!!");
                                                            continue;
                                                }
                                    }
                                    break;
                        }
            }
            public static void main(String []args)
            {
                        pbo2 anak = new pbo2();
                        anak.menu();
            }
}

 RUNNING ( JAVAC pbo2.java)

 
 


 
 

 


 
 
 

Tidak ada komentar:

Posting Komentar