Jumat, 27 Mei 2011

mencari kuadrat ..:)

import java.util.Scanner;
public class kuadrat{
    public static void main (String [] args){
        Scanner input= new Scanner(System.in);
        garis();
        System.out.println("       MENU PILIHAN   ");
        garis();
        System.out.println("1. MENGHITUNG KUADRAT");
        System.out.println("");
        System.out.println("2. EXIT");
        garis();
          System.out.println("Anda pilih nomor :");
          int pil=input.nextInt();
          switch (pil){
              case 1:{
                   System.out.println(" Menghitung mahasiswa");
                     System.out.println("Masukan datanya :");

                 int n=input.nextInt();
         int[]data=new int[10];
         for(int i=1;i<=n;i++){
              System.out.println("Data ke"+i+"=");

              System.out.println("angka :"); int angka=input.nextInt();
            
              int kuadrat = angka*angka;
               System.out.println("hasil kuadrat :" +kuadrat);
               System.out.println(" ");

             
         }
         break;
              }
              default:System.exit(0);
          }}
    static void garis(){
        System.out.println("--------------------------");

                         }


         }

Rabu, 25 Mei 2011

quiss niiiy

import java.util.Scanner;
public class dhiyay {
    public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        garis();
        System.out.println("            MENU PILIHAN                  ");
        garis();
        System.out.println("1. Menhitung Nilai Mahasiswa");
        System.out.println("");
        System.out.println("2. Exit");
        garis();
        System.out.println("");
        System.out.print("Anda pilih no   :");
        int pilih=input.nextInt();

        switch(pilih){
            case 1:{

                int[] npm=new int[20];
                String[] nama=new String[20];
                String[] jur=new String[20];
                String[] mk=new String[20];
                int[] n_tgas=new int[20];
                int[] n_uts=new int[20];
                int[] n_uas=new int[20];


                garis();
                System.out.println("    MENGHITUNG NILAI MAHASISWA");
                garis();
                System.out.println("");
                System.out.print("Masukan jumlah data ="); int n=input.nextInt();

                for(int i=1;i<=n;i++){
                    System.out.println("Data ke"+i +":");
                    System.out.print("NPM           :"); npm[i]=input.nextInt();
                    System.out.print("Nama          :"); nama[i]=input.next();
                    System.out.print("Jurusan       :"); jur[i]=input.next();
                    System.out.print("Mata Kuliah   :"); mk[i]=input.next();
                    System.out.print("Nilai tugas   :"); n_tgas[i]=input.nextInt();
                    System.out.print("Nilai UTS     :"); n_uts[i]=input.nextInt();
                    System.out.print("Nilai UAS     :"); n_uas[i]=input.nextInt();
                    double rata=(n_tgas[i]+n_uts[i]+n_uas[i])/3;
                    System.out.println("Nilai rata-rata ="+rata);

                }
                break;
                }
        default:System.exit(0);
        }
        }
static void garis(){
        System.out.println("==========================================");
    }
}

pertambahan

public class tambah{
    public static void main (String[] args){
        int [] data1={0,1,2,3,4,5};
        int [] data2={0,1,2,3,4,5};
        int jum,i,j;
        System.out.println("+ 0 1 2 3 4 5");
        System.out.println("--------------");
        for(i=0;i<=5;i++){
            System.out.print(i);
            for(j=0;j<=5;j++){
                jum=data1[i]+data2[j];
                System.out.print(" "+jum);
            }
           System.out.println(" ");
        }
    }
}


pengulangan 3 kali

public class bansal{
    public static void main(String [] args){
        String kal1="STMIK BANISALEH";
        String kal2="PEMPROGRAMAN";
        int i,j;
        for(i=1;i<=3;i++){
            System.out.println(" ");
            System.out.println(kal1);
            for(j=1;j<=3;j++){
                System.out.println(kal2);
            }
        }
    }
}


Kamis, 19 Mei 2011

Menu Utama

import java.util.Scanner;
public class menu{
    public static void main (String [] args){
        Scanner input= new Scanner(System.in);
        garis();
        System.out.println("       MENU PILIHAN   ");
        garis();
        System.out.println("1. Menghitung rata - rata");
        System.out.println("");
        System.out.println("2. Menghitung bilangan kelipatan 4");
         System.out.println("");
         garis();
          System.out.println("Anda pilih nomor :");
          int pil=input.nextInt();
          switch (pil){
              case 1:{
                   System.out.println(" Menghitung rata - rata");
                   System.out.println("Masukan jumlah data :");

                 int n=input.nextInt();
                int[]data=new int[10];
                for(int i=1;i<=n;i++){
               System.out.println("Data ke"+i+"=");
               data[i]=input.nextInt();
         }
         int jum=0;
         for(int i=1;i<=n;i++){
             jum=jum+data[i];
         }
          System.out.println("Jumlah =" +jum);
          int rata=jum/n;
           System.out.println("Rata rata =" +rata);
           break;
              }
              case 2:{
                     System.out.println("Menghitung keliapatan 4");
                    System.out.println("Dari =");
                    int nilai_awal=input.nextInt();
                     System.out.println("Sampai =");
                     int nilai_akhir=input.nextInt();
                     for (int i=nilai_awal; i<=nilai_akhir;i++){
                         if (i%4==0){
                             System.out.println(i);
                         }
                     }
                     break;
              }
              default:System.exit(0);
          }}
    static void garis(){
        System.out.println("--------------------------");

                         }
         }
             

mencarii garis


Mencari garis

public class garis{
    public static void main (String [] args){
        garis();
        System.out.println("   MENU UTAMA");
        garis();
        System.out.println("1. Luas segitiga");
         System.out.println("2. Luas lingkaran");
         garis();}
    static void garis(){
        System.out.println("------------------");

    }
}




Output nya 

 

Kamis, 05 Mei 2011

Bintang 5 & 6

-Input Bintang_5-

public class tugas_bintang5 {
public static void main (String [] args){
    int baris,m;
    for(int i=1;i<=7;i++){
        if(i<5){
        for (int j=1;j<=4;j++){
            if (j<=i)
                System.out.print("*");
            else
                System.out.print(" ");
        }}
        else{
            for (int j=1;j<=4;j++){
                m=i+j;
                if(m<=8)
                    System.out.print("*");
            else
                System.out.print(" ");

            }
        }
        System.out.println();
        }
    }

}



-Output-


**
***
****
***
**
*  



-Input Bintang_6-

public class tugas_bintang6 {
public static void main (String [] args){
    int baris,m,x,y,n;
    for(int i=1;i<=7;i++){
        if(i<=4){
        for (int j=1;j<=7;j++){
            if (j<=4){
                m=i+j;
                if (5<=m)
                System.out.print("*");
            else
                System.out.print(" ");
        }
        else{
                x=j-3;
                if(x<=i)
                     System.out.print("*");
            else
                System.out.print(" ");
        }
        }}
        else
            for (int j=1;j<=7;j++){
               if(j<=4){
               y=i-3;
               if(y<=j)
                    System.out.print("*");
            else
                System.out.print(" ");
               }
               else{
                   x=j-3;
                   y=i-3;
                   n=x+y;
                   if(n<=5)
                        System.out.print("*");
            else
                System.out.print(" ");
                 
            }
        }
        System.out.println();
        }
    }

}





-Output-

     * 
   ***
 *****
*******
 *****
   ***
     *  

Bintang 3 & 4

 -Inputan Bintang_3-

import javax.swing.*;
public class tugas_bintang3 {
public static void main (String [] args){
    int baris,x,y;
    baris=Integer.valueOf(JOptionPane.showInputDialog("Masukan banyak bintang?"));
    x=baris+1;
    for(int i=1;i<=baris;i++){
        for (int j=1;j<=baris;j++){
            y=i+j;
            if (x<=y)
                System.out.print("*");
            else
                System.out.print(" ");
        }
        System.out.println();
        }
    }

}


-Output-
     *
   **
  ***
****



-Input Bintang_4-

import javax.swing.*;
public class tugas_bintang4 {
public static void main (String [] args){
    int baris;
    baris=Integer.valueOf(JOptionPane.showInputDialog("Masukan banyak bintang?"));
    for(int i=1;i<=baris;i++){
        for (int j=1;j<=baris;j++){
            if (i<=j)
                System.out.print("*");
            else
                System.out.print(" ");
        }
        System.out.println();
        }
    }

}



-Output-
****
 ***
  **
   *

Bintang 3 & 4

 -Inputan Bintang_3-

import javax.swing.*;
public class tugas_bintang3 {
public static void main (String [] args){
    int baris,x,y;
    baris=Integer.valueOf(JOptionPane.showInputDialog("Masukan banyak bintang?"));
    x=baris+1;
    for(int i=1;i<=baris;i++){
        for (int j=1;j<=baris;j++){
            y=i+j;
            if (x<=y)
                System.out.print("*");
            else
                System.out.print(" ");
        }
        System.out.println();
        }
    }

}


-Output-
     *
   **
  ***
****



-Input Bintang_4-

import javax.swing.*;
public class tugas_bintang4 {
public static void main (String [] args){
    int baris;
    baris=Integer.valueOf(JOptionPane.showInputDialog("Masukan banyak bintang?"));
    for(int i=1;i<=baris;i++){
        for (int j=1;j<=baris;j++){
            if (i<=j)
                System.out.print("*");
            else
                System.out.print(" ");
        }
        System.out.println();
        }
    }

}



-Output-
****
 ***
  **
   *

kamus II

import java.util.Scanner;
public class kamus {
    public static void main(String [] args){
       Scanner Input=new Scanner(System.in);
       String [][]kata = {{"ONE","SATU"},{"COW","SAPI"},{"RUN","LARI"},{"RED","MERAH"},{"MAN","ORANG"}};
       String katadicari;
       System.out.print("kata yang dicari = ");
       katadicari = Input.next();
       int i,k;
       k=-1;
       for(i=0;i<5;i++)
       {
           if (kata[i][0].equals(katadicari.toUpperCase()))
           {
               k=1;
           }
       }
       if (k==-1)
       {
           System.out.println("kata yang di cari tidak di temukan");
       }
       else
       { System.out.println("Terjemahan = 1"+kata[k][1]);
           }
       }
    }

bintang 1 & 2

-Inputan bintang_1-

import javax.swing.*;
public class tugas_bintang1 {
public static void main (String [] args){
    int x;
    x=Integer.valueOf(JOptionPane.showInputDialog("Masukan banyak bintang?"));
    for(int i=1;i<=x;i++){
        for (int j=1;j<=x;j++){
            if (j<=i)
                System.out.print("*");
            else
                System.out.print(" ");
        }
        System.out.println();
        }
    }

}


-output-

**
***
****



-Inputan Bintang_2-

import javax.swing.*;
public class tugas_bintang2 {
public static void main (String [] args){
    int baris,x,y;
    baris=Integer.valueOf(JOptionPane.showInputDialog("Masukan banyak bintang?"));
    x=baris+1;
    for(int i=1;i<=baris;i++){
        for (int j=1;j<=baris;j++){
            y=i+j;
            if (y<=x)
                System.out.print("*");
            else
                System.out.print(" ");
        }
        System.out.println();
        }
    }

}


-Output-
****
***
**
*  

Rabu, 04 Mei 2011

kamuuuss

 yang inii pakaai JOption ..:)



   import javax.swing.*;
    class main{
    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
    // TODO code application logic here
    int [] nomor = {1,2,3,4,5};
    String [] Nama = {"Satu","Sapi","Lari","Merah","Orang"};
    String [] Kamus = {"One","Cow","Run","Red","Man"};
    System.out.println( "Daftar Kamus" );
    System.out.println("No Kata" );
    for(int i=0;i<5;i++)
    System.out.println((i+1) + "  " + Nama[i]);
    JOptionPane.showMessageDialog(null, "KAMUS  indonesia - inggris", "Informasi", JOptionPane.INFORMATION_MESSAGE);
    int hasil;
    do {
    hasil = Integer.valueOf(JOptionPane.showInputDialog("masukan angka :" ));
    if (hasil==nomor[0]){
    JOptionPane.showMessageDialog(null, Nama[0] + " Bahasa Inggrisnya " + Kamus[0]);
    }
    if (hasil==nomor[1]){
    JOptionPane.showMessageDialog(null, Nama[1] +"Bahasa Inggrisnya " + Kamus[1]);
    }
    if (hasil==nomor[2]){
    JOptionPane.showMessageDialog(null, Nama[2] +" Bahasa Inggrisnya " + Kamus[2]);
    }
    if (hasil==nomor[3]){
    JOptionPane.showMessageDialog(null, Nama[3] +" Bahasa Inggrisnya " + Kamus[3]);
    }
    if (hasil==nomor[4]){
    JOptionPane.showMessageDialog(null, Nama[4] +" Bahasa Inggrisnya " + Kamus[4]);
    }

    }
    while (JOptionPane.showConfirmDialog(null, "Mau Coba lagi ?" )
    ==JOptionPane.YES_NO_OPTION);
    }

    }

chatme


ShoutMix chat widget