import java.io.*;
class babIX
{
public
static void main(String[] args) throws Exception
{
DataInputStream
aldy = new DataInputStream(System.in);
MyInput
Input = new MyInput();
CetakSegitiga
CS = new CetakSegitiga();
String
Kalimat, Ulang = "n";
System.out.println("\n===============================================");
System.out.println("Nama\t\t: xxxxxxxxxxxxxxxxxxxxxx");
System.out.println("Npm\t\t: xxxxxxxxxxxxxxxxxxxxxxx");
System.out.println("===============================================\n");
do
{
Kalimat
= Input.InputString();
CS.Cetak(Kalimat);
System.out.println("\n===============================================");
System.out.print("Apakah anda ingin mengulang
kembali(y/t):");
Ulang
= aldy.readLine();
Ulang
= Ulang.toLowerCase();
System.out.println("===============================================\n");
}
while
(Ulang.equals("y"));
}
}
class MyInput
{
public
String InputString() throws Exception
{
DataInputStream
aldy = new DataInputStream(System.in);
System.out.print("\nMasukkan
kalimat\t: ");
String
Input = aldy.readLine();
System.out.println("===============================================\n");
return
Input;
}
}
class CetakSegitiga
{
public
static void Cetak(String Kalimat) throws Exception
{
int
Panjang = Kalimat.length()-1;
int
Bantu = Panjang;
for
(int j=Panjang; j>=0; j--)
{
for
(int K=0; K<=j; K++)
{
System.out.print("
");
}
for
(int L=Bantu; L<=Panjang; L++)
{
System.out.print(Kalimat.charAt(L));
}
Bantu = Bantu-1;
System.out.println();
}
}
}
Tidak ada komentar:
Posting Komentar