using System;
using System.Threading;
namespace latihan_4
{
class Program
{
static void Main()
{
//a=a berulang -> a++
//a=a+2 -> a+2
//perulangan terbatas
int x = 0, k; //1 2 4 7 11 16 22 dst
for (int i = 1; i <= 10; i++)
{
k = x + i;
Console.Write(k);
Console.Write(", ");
x = k - 1;
}
Console.WriteLine();
string Nama;
Console.Write("Ketik Nama Anda :");
Nama = Console.ReadLine();
int Tunda, kol, bar;
// jalan ke kanan
for (kol = 1; kol <= 80 - Nama.Length - 2; kol++)
{
Console.SetCursorPosition(kol, 5);
Console.Write(" " + Nama);
Thread.Sleep(100);
}
// jalan ke bawah
for (bar = 5; bar <=20; bar++)
{
Console.SetCursorPosition(kol, bar - 1);
Console.Write(new string(' ', Nama.Length));
// CETAK KATA
Console.SetCursorPosition(kol, bar);
Console.Write(Nama);
Thread.Sleep(100);
}
// JALAN KE KIRI
int n;
for (n = 0; n < Nama.Length; n++)
{
for (kol=(79-Nama.Length) +n; kol>=n; kol--)
{
Console.SetCursorPosition(kol, bar-1);
Console.Write(Nama.Substring(n,1));
Thread.Sleep(100);
if (kol > n)
{
Console.SetCursorPosition(kol, bar - 1);
Console.Write(" ");
}
}
}
// keatas
for (n = 0; n < Nama.Length; n++)
{
for (bar=(20-Nama.Length) +n; bar >=n; bar--)
{
Console.SetCursorPosition(n, bar);
Console.Write(Nama.Substring(n,1));
Thread.Sleep(120);
if (bar > n)
{
Console.SetCursorPosition(n, bar);
Console.Write(" ");
}
}
}
//perulangan bersyarat
string Keluar = "N";
while (Keluar.ToUpper() =="N")
{
Console.Write(" Anda ingin keluar dari aplikasi [Y/N] : ");
Keluar = Console.ReadLine();
}
}
}
}
Sign up here with your email