This is default featured post 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Rabu, 22 Maret 2017

Program gerobak fried chicken

Code program :

import java.util.*;

class TUGASARRAY
{
public static void main (String[] args) throws Exception
    {
     String[] kode = new String[10];
        String[] jenis = new String[10];
        int i,j;
        double jumlah=0 ,pjk=0, total=0;
        int[] potong = new int[10];
        int[] harga = new int[10];
        int[] jml = new int[10];

        Scanner input = new Scanner(System.in);

     System.out.println();
     System.out.println(" GEROBAK FRIED CHICKEN ");
     System.out.println();
     System.out.println("-----------------------");
     System.out.println("Kode   Jenis    Harga ");
     System.out.println("-----------------------");
     System.out.println(" D     Dada     Rp.2500");
     System.out.println(" P     Paha     Rp.2000");
     System.out.println(" S     Sayap    Rp.1500");
     System.out.println("-----------------------");

     System.out.println();
     System.out.print("Banyak Jenis : ");
     j=input.nextInt();

     for(i=0; i<j; i++)
     {
     System.out.println("\nJenis Ke - " + (i+1));
     System.out.print("Jenis Potong [D/P/S] : ");
     kode[i]= input.next();

            if ("D".equals(kode[i]) || "d".equals(kode[i]))
            {
            jenis[i]="Dada";
            harga[i]=2500;
            }
            else if ("P".equals(kode[i]) || "p".equals(kode[i]))
            {
            jenis[i]="Paha";
            harga[i]=2000;
            }
            else
            {
            jenis[i]="Sayap";
            harga[i]=1500;
            }


     System.out.print("Banyak Potong        : ");
     potong[i] = input.nextInt();

            jml[i]=harga[i]*potong[i];
     }

     System.out.println("\n\tGEROBAK FRIED CHICKEN            ");
     System.out.println("---------------------------------------------");
     System.out.println("No.\tJenis\tHarga\tBanyak\tJumlah");
     System.out.println("\tPotong\tSatuan\tBeli\tHarga ");
     System.out.println("---------------------------------------------");

        for(i=0;i<j;i++)
        {
            System.out.println(+(i+1)+ "\t" +jenis[i]+ "\t" +harga[i]+ "\t" +potong[i]+ "\t\t" +jml[i]);
            jumlah=jumlah+jml[i];
        }

        System.out.println("---------------------------------------------");


        pjk=jumlah*0.1;
        total=jumlah+pjk;

        System.out.println("\tJumlah Bayar\t\t\t" +jumlah);
        System.out.println("\tPajak 10%\t\t\t\t" +pjk);
        System.out.println("\tTotal Bayar\t\t\t\t" +total);

    }

}

Ouput/ hasil keluaran nya:


Jumat, 17 Maret 2017

Program hitungan deret 10 genap dan ganjil serta program menampilkan deret fibonanci dan bilangan Prima

1. Buatlah program untuk menghitung 10 deret bilangan genap ;
      input / program tsb ;......

 "     import java.io.*;

class genap

{
public static void main(String[]args){
int i = 0;
int x = 0;
System.out.print("Deret: ");
while(x<20){
if (i%3==0)
i++;
x = 2 * i;
System.out.print(" "+ x +", ");
i++;}
System.out.println(" ");
}
}     "

inilah hasil output program ini :




2.  Buatlah program untuk menghitung 10 deret bilangan ganjil ;

input program tersebut ;

"  public class array2
{
    public static void main(String[] args) {
        int [] bil = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19 };
        System.out.println("");
       System.out.print("Bilangan Ganjil :  ");
       for (int i = 0; i < bil.length; i++){
           if (bil [i] % 2!= 0){
               System.out.print(bil[i] + " ");
           }
       }
       System.out.println("");
   }
}
"

inilah hasil program tersebut ;




3.  program untuk menampilkan deret fibonanci ;

input program fibinaci ;

"   class deretfibonacci
{
public static void main (String [] args)
{
int  t=0, p=1, hasil=0;
int x = Integer.parseInt(s);
for(int i=1; i<=x; i++){
t=p;
p=hasil;
System.out.print(hasil+" ");
hasil=t+p;
}
}
}

"

hasil output program fibonacci ;



4. program untuk menampilkan bilangan prima ;

input program bilangan prima ;

"    import java.util.Scanner;
public class prima
{
                public static void main (String [] args)
                {
                                Scanner input = new Scanner(System.in);
                               
                                int x=2;
                                int hitung=1;
                                boolean prima;
                               
                                System.out.print("input angka = ");
                                int angka = input.nextInt();
                               
                                while (hitung<=angka)
                                {
                                                prima = false;
                                                if (x==2 || x==3 || x== 5)
                                                {
                                                                prima = true;
                                                }
                                                else if (x%2 !=0)
                                                {
                                                                if (x%3 !=0)
                                                                {
                                                                                if(x%5 !=0)
                                                                                {
                                                                                                prima = true;
                                                                                }
                                                                }
                                                }
                                                if (prima==true)
                                                {
                                                                System.out.print(x+" ");
                                                                hitung++;
                                                }
                                                x++;
                                }
                }
}


"

output program bilangan prima ;


Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More