Docstoc

tugas

Document Sample
tugas Powered By Docstoc
					                                    Jawaban Praktikum Modul 1


    1. Flouchart

                                start




                   Boolean ulang = true




                        While==ulang




                              deret




                                                      Ya
                                                                              Inputan harus
                           Deret%2==0                                             ganjil


                        Tidak


                              L=1
                           n=deret/2+1




                        For i=1 to n do



                                   Tidak
                i==n


             Ya                                            For k=1 to n to

         For j=1 to deret do

                                                              Print(“ “)

             Print(“+“)


                                                               endfor

               endfor
                                                           For j=1 to l do




                                        Print(“+“)    Ya
                                                               J==1


                                                                     Tidak


                                                      Ya
                                        Print(“+“)             J==l/2


                                                                     Tidak

                                                              Print(“ “)




                                                      Ya
                                         Print(“+“)            J==l-2


                                                                      Tidak


                                                               endfor

D                      C                   L+=2                                    B          A
D                                       C                                B   A




                                   Println()




                                    endfor



                                     L-=2



                            For i=(n-1) to 1 do



                            For i=(n-1) to 1 do



                                   Print(“ “)




                                    endfor




                                For j=l to 1 do


                                                  Ya
                                    J==1                    Print(“+“)


                                Tidak

                                                  Ya        Print(“+“)
                                  J==(l+3)/2

                                Tidak

                                   Print(“ “)




                                    J==3          Ya        Print(“+“)


                                Tidak

                                    endfor




                                     L-=2



                                   Println()




                                    endfor



                           Apakan anda ingin
                           mengulang y/t? (u)



                        Tidak                          Ya
    end   Ulang=false                U==t
Source Code
import java.io.*;
class tugas2_1
{
       public static void main(String[]args) throws Exception
       {
                 boolean ulang=true;
                 DataInputStream input= new DataInputStream(System.in);
                 System.out.println("***********************************");
                 System.out.println("");
                 System.out.println(" Nama = Moch Lutfi Alief");
                 System.out.println("");
                 System.out.println(" N P M = 06.2009.1.04967");
                 System.out.println("");
                 System.out.println("***********************************");
                 System.out.println("");
                 System.out.println("");
                 while (ulang)
                 {
                        System.out.print("Jumlah Deret = ");
                        int deret = Integer.parseInt(input.readLine());
                        if (deret%2==0)
                        {
                                 System.out.println("Inputan Harus Ganjil");
                        }
                        else
                        {
                                 int l = 1;
                                 int n=deret/2+1;
                                 for(int i=1;i<=n;i++)
                                 {
                if (i==n)
                {
                        for (int j=1;j<=deret;j++)
                        {
                               System.out.print("+");
                        }
                }
else
  {
       for(int k=n;k>i;k--)
                {
           System.out.print(" ");
       }
       for(int j=1;j<=l;j++)
       {
                if (j==1)
                {
                System.out.print("+");
       }
                if (j==l/2)
       {
                System.out.print("+");
                }
       else
       {
                System.out.print(" ");
                }
       if (j==l-2)
       {
                System.out.print("+");
       }
              }
              l+=2;
              }
    System.out.println("");
              }
    l -= 2;
    for(int i=(n-1);i>=1;i--)
{
    for(int k=i;k<=(n-1);k++)
    {
    System.out.print(" ");
    }
              for(int j=l;j>=1;j--)
    {
              if (j==l)
    {
              System.out.print("+");
    }
              if (j==(l+3)/2)
    {
              System.out.print("+");
    }
    else
              {
                      System.out.print(" ");
              }
    if (j==3)
    {
                      System.out.print("+");
              }
    }
                   l-=2;
                 System.out.println("");
                   }
            }
            System.out.println("___________________________________");
            System.out.print("Apakah anda ingin mengulang y/t :");
            String u=input.readLine();
            if(u.startsWith("t"))
            {
                   ulang=false;
            }
      }
      }
}
Print Out
2. Flowchart
                          start




                  Batas akhir (in)
           deret kelipatan ke (kelipatan)




                       Int a=1
                  int b= kelipatan
                   int jumlah = 0



                  For i=2 to in do



                       int tm=0



                  For j=1 to i do



                                            ya
                    I mod j = 0

                                                 tm++
                  tidak



                       endfor




                       tm ==2


                  ya


                                     tidak
                   a== kelipatan                  i



                    ya                  Jumlah= jumlah +i

                          Hanif



                  Kelipatan = b+
                    kelipatan




                       tm=tm+1




                       endfor




                       jumlah




                          End
Source Code
import java.io.*;
class tugas2_2
{
       public static void main(String[] args)throws Exception
       {
                 System.out.println("***********************************");
                 System.out.println("");
                 System.out.println(" Nama = Moch Lutfi Alief");
                 System.out.println("");
                 System.out.println(" N P M = 06.2009.1.04967");
                 System.out.println("");
                 System.out.println("***********************************");
                 System.out.println("");
                 System.out.println("");
                 DataInputStream input=new DataInputStream(System.in);
                 System.out.print("Batas Akhir = ");
                 int in = Integer.parseInt(input.readLine());
                 System.out.print("Deret kelipatan ke = ");
                 int kelipatan = Integer.parseInt(input.readLine());
                 int a=1;
                 int b=kelipatan;
                 int jumlah=0;
                 for(int i = 2; i <= in; i++)
                 {
                         int tm = 0;
                         for(int j = 1; j <= i; j++)
                         {
                                 if(i % j == 0)
                                 tm++;
                         }
                   if(tm == 2)
                   {
                   if (a==kelipatan)
                           {
                                    System.out.print("Lutfi ");
                                    kelipatan=b+kelipatan;
                           }
                           else
                           {
                                    System.out.print(i + " ");
                                    jumlah=jumlah+i;
                           }
                           a=a+1;
                   }
            }
            System.out.println();
            System.out.println("Jumlah = "+jumlah);
      }
}
Print Out
        3. Flowchart

                                                        start



                       1. mencari bilangan yang habis dibagi 3 dan tidak habis dibagi 5 & 7
                       2. mencari deret bilangan fibonacci
                       3. mencari deret bilangan genap yang tidak habis dibagi 6



                                                        Pilih



                                                    Switch (pilih)




                                                          2
       1                                                                                               3



     a=1                                            Jumlah deret                                     deret


     batas
                                                        x=0                                   For d = 1 to deret do
                                                        y=1


   a <= batas
                                                For I = 1 to deret do                             d mod 2 = 0



                                                      z=x+y
 a mod 3 == 0                                          x=y
                                                       y=z
                                                                                                  d mod 6 != 0

                                                          z

(a mod 5!= 0) &&                                                                                       d
  (a mod 7 != 0)
                                                       Endfor

                                                                                                     Endfor
       a
                                                       break

                                                                                                     break
    a+=1




     break




                                                        End
Source Code
      import java.io.*;
      class tugas2_3
      {
              public static void main(String[] args)throws Exception
              {
              System.out.println("***********************************");
              System.out.println("");
              System.out.println(" Nama = Moch Lutfi Alief");
              System.out.println("");
              System.out.println(" N P M = 06.2009.1.04967");
              System.out.println("");
              System.out.println("***********************************");
              System.out.println("");
              System.out.println("");
              System.out.println("Program Swicth Case\n");
              DataInputStream input= new DataInputStream(System.in);
              System.out.println("===============================");
              System.out.println("1. Mencari deret bilangan yang habis dibagi 3
              dan tidak habis dibagi 5 dan 7");
              System.out.println("2. Mencari deret fibonacci");
              System.out.println("3. Mencari deret bilangan genap yang tidak
              habis dibagi 6");
              System.out.println("===============================");
              System.out.print("Masukkan nomor pilihan Anda = ");
              int pilih=Integer.parseInt(input.readLine());
              switch (pilih)
              {
                       case 1:
                       int a=1;
                       System.out.print("Batasan = ");
int batas=Integer.parseInt(input.readLine());
while (a<=batas)
{
          if (a%3==0)
          {
                  if ((a%5!=0)&&(a%7!=0))
                  {
                           System.out.print(a+" ");
                  }
          }
          a+=1;
}
break;
case 2:
System.out.print ("Inputkan jumlah deret = ");
int deret = Integer.parseInt(input.readLine ());
int x = 0;
int y = 1;
for (int i=1; i<=deret; i++)
{
          int z = x + y;
          x=y;
          y=z;
          System.out.print(z+" ");
}
break;
case 3:
System.out.print ("Inputkan jumlah deret = ");
deret = Integer.parseInt(input.readLine ());
for (int d=1;d<=deret;d++)
{
                 if (d%2==0)
                 {
                       if (d%6!=0)
                       {
                               System.out.print(d+" ");
                       }
                 }
        }
        break;
        }
    }
}
OUTPUT

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:179
posted:6/6/2011
language:Indonesian
pages:14
Description: tugas resmi modul 2