# Progam Resmi Modul 9

Flowchart main Program :
start prosess(pilih); i=0;i<=11;i++;

try Pilih; catch “Inputan Salah” prosess(pilih);

1

2

3

4

5

6

7

8

9

10

11

default ;

a.tampil();

c.tampil();

e.tampil();

g.tampil();

i.tampil();

k.tampil();

b.tampil();

d.tampil();

f.tampil();

h.tampil();

j.tampil();

“Inputan Salah”

“Program berakir”

end

Flowchart Package Tgs11,Tgs12,Tgs13,Tgs14 :
a.tam il p () ; b.tam il p () ;

A las ; T gg ; in i D eter iam ; L as =0.5*alas *ting u gi ; L as u L k ing aran =0.5*3.1 *D eter 4 iam L rsir =L A uas -L;

K ata 1; K ata 2;

;

H asil =”k ata 1.u perC p ase”

+”kata 2.low ase” erC

;

L arsir

;

H asil ;

c.tam il p

() ;

d.tam il p

() ;

U S ; A US ; T As ; b

A; B

T = 0.4*U S )+ 0.5*U S ) ( 0.1*A s ); ot ( T ( A + b

S =A; f A=B; B=S ; f

T ; ot

A,B

Progam Resmi Modul 9
Flowchart Package Tgs21, Tgs22:

e.tampil ();

f.tampil ();

i=1;i<=500 ;i++

Kata 1; Kata 2;

i%5==0
TIDAK

YA

i

pjg 1=kata 1.length (); pjg 2=kata 2.length (); Temp =kata 1; kata 2=kata 1; kata 1=temp ;

pjg 2>pjg 1
TIDAK

YA

Hasil = "+ kata 1+" "+ kata 2

Hasil = "+ kata 1+" "+ kata 2

Hasil ;

Flowchart Package Tgs23:
KPK (A,B) FPB (A,B)

g.tampil ();

kpk =0;

hsl _bg=m%n;

A; B;

i=1;i<=n;i++ hsl_bg!= 0 kpk =kpk +m; YA

m = n; n = hsl _bg; hsl_bg = m%n;

KPK (A,B); FPB (A,B);

TIDAK kpk % n==0 YA TIDAK return n ;

return kpk ;

Progam Resmi Modul 9
Flowchart Package Tgs31;
h.ta p mil k ta ; a b 1; ts b 2= 0; ts bs 2=bs 1; t t i=0;i<k ta .le g a n th ( ;i+ ) +
Y A

( ; )

i+1= bs = t 2
T A ID K

b 2=b 2+b 1; ts ts ts te p =k ta .s b trn m a us i g (i,i+1);

k t .c a A aa hr t

(i);

te p .t U p r a e m o p eC s ;

( )

Flowchart Package Tgs32;
i.tampil();

a; b; i=0;i<matr1.length;i++ j=0;j<matr1[i].length;j++ matr1[i][j] ; tampil(matr[][]); jumlah (matr1,matr2,a,b);

i=0;i<matr.length;i++ j=0;j<matr[i].length;j++ i=0;i<matr2.length;i++ j=0;j<matr2[i].length;j++ matr2[i][j] ; matr1[i][j] ;

i=0;i<a;i++

j=0;j<b;j++

matr_hasil[ i][j]=matr1[i][j]+matr2[i][j];

tampil( matr1);

tampil( matr2);

tampil(matr_hasil[ i][j]);

jumlah(matr1,matr2,a,b);

Progam Resmi Modul 9
Flowchart Package Tgs41;
j.ta m p(); il

k a ta ;

b ts =4; 1 b ts=b ts ; 2 1 c a tc h try i=0;i<k a tale n g th + . ();i+ T ID A K YA (i+1!=b ts )& & 3) 2 (i<1

a n g k=In te g .pra rs e In ta ta u b s trin g a e (k .s (i,i+1)); h a sil"IS B N v a lid = ";

h a sil "IS B N a lid; = Inv "

T ID A K k a tac h a rA t = . (i)= '-'

YA

b ts =b ts +b ts ; 2 2 1 h a s = "IS B N v a lid il ";

h a sil "I S B N a lid; = Inv "

h a sil

Progam Resmi Modul 9
Flowchart Package Tgs42;
k.tam pil); ( kalim at ; chars ] = kalim at harA rray [ .toC (); banding kalim at harA rray []= .toC (); i=0;i<charslength . ;i++

(chars i]!=' ') & &test(charsbanding [ , ,i) T ID A K

YA

"charsi]+ " [ " +hitung (charsi)+"; ,

j=0;j<charslength . ;j++

charsi]= =charsj] [ [ T ID A K

YA

j+1;

hitung (chars i) [], temp=chars [i]; jumlah 0; = j=0;j<chars .length ;j++ YA temp==chars j] [ TID A K jum lah ++;

test( chars ],banding],i) [ [ temp=chars [i]; jumlah =0; j=0;j<=i;j++; YA temp==bandingj] [ T ID A K jumlah ++;

jumlah <2 R eturn ; TID A K false;

YA

true;

R eturn ;

Progam Resmi Modul 9
Output Program : Output Main Menu :

Output pilihan program 1:

Setelah progam pilihan berakir kembali ke main program pilihan .

Progam Resmi Modul 9
Output pilihan program 2:

Output pilihan program 3:

Output pilihan program 4:

Progam Resmi Modul 9
Output pilihan program 5:

Output pilihan program 6:

Output pilihan program 7:

Progam Resmi Modul 9

Output pilihan program 8:

Output pilihan program 9:

Progam Resmi Modul 9

Output pilihan program 10: Jika inputan benar :

Jika inputan salah :

Output pilihan program 11:

Progam Resmi Modul 9

Output Program jika inputan tidak sesuai : Ada 11 kesempatan pemilihan , setelah itu program akan selesai !

//Source Code Program Main : import java.io.*; import Tgs4.Tgs11; import Tgs4.Tgs12; import Tgs4.Tgs13; import Tgs4.Tgs14; import Tgs4.Tgs21; import Tgs4.Tgs22; import Tgs4.Tgs23; import Tgs4.Tgs31;

Progam Resmi Modul 9
import Tgs4.Tgs32; import Tgs4.Tgs41; import Tgs4.Tgs42; class ProgUtama{ public static void main(String[] args)throws Exception { for(int i=0;i<=11;i++) { DataInputStream ww=new DataInputStream(System.in); System.out.println("\n------------------------------------------------------------------"); System.out.println("\t\t\tTuGas Resmi\n"); System.out.println("------------------------------------------------------------------\n"); System.out.println("1. Menghitung Luas SegiTiga di dalam Lingkaran\n"); System.out.println("2. Mencetak huruf besar pada kalimat huruf kecil dan sebaliknya\n"); System.out.println("3. Menghitung Nilai akhir yg didapat dari 40%UTS , 50%UAS , 10%Absen \n"); System.out.println("4. Swap File\n"); System.out.println("5. Membuat deret bilangan yang habis dibagi 5,antara bilangan 1-500\n"); System.out.println("6. Membandingkan 2 kata,jika salah satu lebih panjang, kata itu diganti huruf besar semua\n"); System.out.println("7. Menghitung KPK dan FPB\n"); System.out.println("8. Mengubah huruf kecil menjadi huruf besar dengan posisi huruf yang ditentukan user\n"); System.out.println("9. Penjumlaha Array 2 dimensi(penjumlahan Matrix)\n"); System.out.println("10. Input ISBN dengan ketentuan inputan 13 char angka,tiap karakter keempat diisi '-'(Strip)\n"); System.out.println("11. Mengetahui jumlah dan posisi suatu huruf dari kalimat\n"); System.out.print("\tTugas ke berapa pilihan anda ? "); try { int pilih=Integer.parseInt(ww.readLine()); prosess(pilih); }catch(Exception e){ System.out.println("\t\tInputan Salah!!!!!!"); } } }

Progam Resmi Modul 9
public static void prosess(int pilihan)throws Exception { System.out.println("\n---------------------------------------------------------------------"); System.out.println("\t\tProgram Pilihan Anda"); System.out.println("---------------------------------------------------------------------\n"); switch(pilihan) { case 1: Tgs11 a=new Tgs11(); a.tampil(); break; case 2: Tgs12 b=new Tgs12(); b.tampil(); break; case 3: Tgs13 c=new Tgs13(); c.tampil(); break; case 4: Tgs14 d=new Tgs14(); d.tampil(); break; case 5: Tgs21 e=new Tgs21(); e.tampil(); break; case 6: Tgs22 f=new Tgs22(); f.tampil(); break; case 7: Tgs23 g=new Tgs23(); g.tampil(); break;

Progam Resmi Modul 9
case 8: Tgs31 h=new Tgs31(); h.tampil(); break; case 9: Tgs32 i=new Tgs32(); i.tampil(); break; case 10: Tgs41 j=new Tgs41(); j.tampil(); break; case 11: Tgs42 k=new Tgs42(); k.tampil(); break; default: System.out.println("Inputan anda tidak sesuai"); break; } System.out.println("\nProgram Pilihan berakir"); } } // Package Tgs11 package Tgs4; import java.io.*; public class Tgs11 { public void tampil()throws Exception { DataInputStream ww= new DataInputStream(System.in); double Luas, L, LArs; //input alas System.out.print("Input Alas STiga String x= ww.readLine(); double alas=Double.parseDouble(x); //input tinggi = ");

Progam Resmi Modul 9
System.out.print("Input Tinggi STiga = "); String o= ww.readLine(); double ting=Double.parseDouble(o); //input Diameter System.out.print("Input diameter String k= ww.readLine(); double dm=Double.parseDouble(k); //Proses Luas=0.5*alas*ting; L=0.5*3.14*dm; LArs=Luas-L; //Output System.out.println("Luas Arsiran } } = "+LArs); = ");

// Package Tgs12 package Tgs4; import java.io.*; public class Tgs12{ public void tampil()throws Exception { DataInputStream ww= new DataInputStream(System.in); String kata1,kata2; System.out.println("Input = "); System.out.print(" kata1=ww.readLine(); System.out.print(" kata2=ww.readLine(); System.out.println("Output = "+kata1.toUpperCase()+" "+kata2.toLowerCase()); Kata 2 = "); Kata 1 = ");

Progam Resmi Modul 9
} } // Package Tgs13 package Tgs4; import java.io.*; public class Tgs13{ public void tampil()throws Exception { DataInputStream ww= new DataInputStream(System.in); int UTS,UAS,Abs; double Tot; //Input Data System.out.print("Nilai UAS ="); String x= ww.readLine(); UAS=Integer.parseInt(x); System.out.print("Nilai UTS ="); String o= ww.readLine(); UTS=Integer.parseInt(o); System.out.print("Nilai Absen ="); String p= ww.readLine(); Abs=Integer.parseInt(p); //Proses nilai total Tot=(0.4*UTS)+(0.5*UAS)+(0.1*Abs); //+50/100*UAS+10/100*Abs //Output System.out.println("Nilai Total = "+Tot); } } // Package Tgs14 package Tgs4; import java.io.*; public class Tgs14{ public void tampil()throws Exception { DataInputStream ww= new DataInputStream(System.in); int A,B,Sf;

Progam Resmi Modul 9
//Input A,B System.out.print("A = "); String x= ww.readLine(); A=Integer.parseInt(x); System.out.print("B = "); String o= ww.readLine(); B=Integer.parseInt(o); //Proses Sf=A; A=B; B=Sf; //Output System.out.println("A = "+A); System.out.println("B = "+B); } }

// Package Tgs21 package Tgs4; import java.io.*; public class Tgs21{ public void tampil()throws Exception { for(int i=1;i<=500;i++) { if(i%5==0) { System.out.print(i+" "); } } }

Progam Resmi Modul 9
} // Package Tgs22 package Tgs4; import java.io.*; public class Tgs22{ public void tampil()throws Exception { DataInputStream ww=new DataInputStream(System.in); //input kata System.out.print("kata 1= "); String kata1=ww.readLine(); System.out.print("kata 2= "); String kata2=ww.readLine(); //PROSES int pjg1=kata1.length(); int pjg2=kata2.length(); if(pjg1<pjg2) { //output System.out.println("Panjang kal 1 = "+pjg1); System.out.println("Panjang kal 2 = "+pjg2); System.out.println("Hasil = "+kata2+" "+kata1); } else { //output System.out.println("Panjang kal 1 = "+pjg1); System.out.println("Panjang kal 2 = "+pjg2); System.out.println("Hasil = "+kata1+" "+kata2); } } } // Package Tgs23 package Tgs4; import java.io.*; public class Tgs23{ public void tampil()throws Exception

Progam Resmi Modul 9
{ //Input Data DataInputStream xx=new DataInputStream(System.in); System.out.print("masukan bilangan A = "); int A=Integer.parseInt(xx.readLine()); System.out.print("masukan bilangan B = "); int B=Integer.parseInt(xx.readLine()); //Proses dan Output System.out.println("KPK dari A dan B adalah : "+ KPK(A,B)); System.out.println("FPB dari A dan B adalah : "+ FPB(A,B)); } //procedure KPK public static int KPK(int m,int n){ int kpk=0; for(int i=1;i<=n;i++) { kpk=kpk+m; if(kpk % n==0) { break; } } return kpk; } //procedure FPB public static int FPB(int m,int n){ int hsl_bg=m%n; while (hsl_bg!=0) { m = n; n = hsl_bg; hsl_bg = m%n; } return n; } } // Package Tgs31

Progam Resmi Modul 9
package Tgs4; import java.io.*; public class Tgs31{ public void tampil()throws Exception { DataInputStream xxx=new DataInputStream(System.in); System.out.print("kalimat String kata=xxx.readLine(); System.out.print("batas geser = "); int bts1=Integer.parseInt(xxx.readLine()); int bts2=bts1; System.out.print("hasil = "); for(int i=0;i<kata.length();i++) { if(i+1==bts2) { bts2=bts2+bts1; String temp=kata.substring(i,i+1); System.out.print(temp.toUpperCase()); } else { System.out.print(kata.charAt(i)); } } System.out.println(); } } // Package Tgs32 package Tgs4; import java.io.*; public class Tgs32{ public void tampil()throws Exception { DataInputStream xxx=new DataInputStream(System.in); int a,b; System.out.print("Input banyak baris = "); = ");

Progam Resmi Modul 9
a=Integer.parseInt(xxx.readLine()); System.out.print("Input banyak kolom = "); b=Integer.parseInt(xxx.readLine()); int matr2[][]=new int[a][b]; int matr1[][]=new int[a][b]; System.out.println("Input data Matrix 1 :"); //input data pada matrix1 for (int i=0;i<matr1.length;i++){ for (int j=0;j<matr1[i].length;j++) { System.out.print("Masukan elemen matrix1 baris "+(i+1)+" kolom "+(j+1)+" : "); matr1[i][j] = Integer.parseInt(xxx.readLine()); } } System.out.println("Input data Matrix 2 :"); //input data pada matrix2 for (int i=0;i<matr2.length;i++){ for (int j=0;j<matr2[i].length;j++) { System.out.print("Masukan elemen matrix2 baris "+(i+1)+" kolom "+(j+1)+" : "); matr2[i][j] = Integer.parseInt(xxx.readLine()); } } System.out.println("\n Penjumlahan matrix1 + matrix2"); System.out.println("====================================="); tampil(matr1); System.out.println("\n\n"); tampil(matr2); System.out.println("_______________________+"); jumlah(matr1,matr2,a,b); } //prosedur jumlahkan matrix1 dan matrix2 public static void jumlah(int matr1[][],int matr2[][],int a,int b) { int matr_hasil[][]=new int[a][b]; for(int i=0;i<a;i++) {

Progam Resmi Modul 9
for(int j=0;j<b;j++) { matr_hasil[i][j]= matr1[i][j]+matr2[i][j]; } }System.out.println(); tampil(matr_hasil); } //prosedur tampilkan hasil public static void tampil(int matr[][]) { for (int i=0;i<matr.length;i++) { System.out.println(); for (int j=0;j<matr[i].length;j++) { System.out.print(" "+matr[i][j]+" } System.out.println(); } } } // Package Tgs41 package Tgs4; import java.io.*; public class Tgs41{ public void tampil()throws Exception{ DataInputStream xx=new DataInputStream(System.in); System.out.print("ISBN = "); String kata=xx.readLine(); System.out.print("\n"); int angka; int bts1=4; int bts2=bts1; String hasil=null; try ");

Progam Resmi Modul 9
{ for(int i=0;i<kata.length();i++) { if((i+1!=bts2)&&(i<13)) { angka=Integer.parseInt(kata.substring(i,i+1)); hasil="ISBN valid"; } else if(kata.charAt(i)=='-') { bts2=bts2+bts1; hasil="ISBN valid"; } else { hasil="ISBN Invalid"; break; } } } catch(Exception e){hasil="ISBN Invalid";} System.out.println("\n"+hasil+"\n"); } } //Package Tgs42 package Tgs4; import java.io.*; public class Tgs42{ public void tampil()throws Exception { DataInputStream xx=new DataInputStream(System.in); System.out.print("Masukan Kalimat : "); String kalimat = xx.readLine(); System.out.print("Input : "+kalimat+"\n\n"); System.out.println("Output : \n"); char chars[] = kalimat.toCharArray(); char banding[]= kalimat.toCharArray(); for(int i=0;i<chars.length;i++)

Progam Resmi Modul 9
{ if((chars[i]!=' ')&&test(chars,banding,i)) { System.out.print("\tJumlah huruf "+chars[i]+" = "+hitung(chars,i)+" Pada posisi "); for(int j=0;j<chars.length;j++) { if(chars[i]==chars[j]) { System.out.print((j+1)+","); } } System.out.println(); } } } //hitung karakter public static int hitung(char chars[],int i) { char temp=chars[i]; int jumlah=0; for(int j=0;j<chars.length;j++) { if(temp==chars[j]) { jumlah++; } } return jumlah; } //test sudah belum public static boolean test(char chars[],char banding[],int i) { char temp=chars[i]; int jumlah=0; for(int j=0;j<=i;j++) {

Progam Resmi Modul 9
if(temp==banding[j]) { jumlah++; } } if(jumlah<2){ return true; } else{ return false; } } }