Professional Documents
Culture Documents
enum anggotaa
{
Nonmember=0,silver,gold,platinum
}
struct anggota
{
public string nama, alamat, email,disc;
public int telepon;
}
static void Main(string[] args)
{
anggota a;
anggotaa tipe;
int kode;
Console.Write("Masukan Nama Customer : ");
a.nama = Console.ReadLine();
Console.Write("Masukan Alamat : ");
a.alamat = Console.ReadLine();
Console.Write("Masukan Email : ");
a.email = Console.ReadLine();
Console.Write("Masukan No.Telp : ");
a.telepon = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("0:NonMember");
Console.WriteLine("1:Silver");
Console.WriteLine("2:Gold");
Console.WriteLine("3:Platinum");
Console.Write("Masukan Keanggotaan[0-3] : ");
kode = int.Parse(Console.ReadLine());
tipe = (anggotaa)kode;
Console.Clear();
if (kode == 0 | kode == 1 | kode == 2 | kode == 3)
{
switch (tipe)
{
case anggotaa.Nonmember:
Console.WriteLine("Keanggotaan : Nonmember");
Console.WriteLine("Diskon : 0%");
break;
case anggotaa.silver:
Console.WriteLine("Keanggotaan : Silver");
Console.WriteLine("Diskon : 5%");
break;
case anggotaa.gold:
Console.WriteLine("Keanggotaan : Gold");
Console.WriteLine("Diskon : 10%");
break;
case anggotaa.platinum:
Console.WriteLine("Keanggotaan : Platinum");
Console.WriteLine("Diskon : 15%");
break;
}
}
else
{
Console.WriteLine("Inputan Pada Keanggota Salah ! ");
}
Console.WriteLine("===========================");
Console.ReadKey();
}8
struct labo
{
public string nama, lantai, kapasitas, kipas, proyektor, ac, internet;
public bool pilihan;
}
static void Main(string[] args)
{
labo lab;
labo lab1;
//proyektor
Console.Write("Ada Proyektor (true/false) : ");
lab.proyektor = Console.ReadLine().ToLower().Trim();
//AC
Console.Write("Ada AC? (true/false) : ");
lab.ac = Console.ReadLine().ToLower().Trim();
//internet
Console.Write("Ada Internet (true/false) : ");
lab.internet = Console.ReadLine().ToLower().Trim();
Console.WriteLine();
//proyektor
Console.Write("Ada Proyektor (true/false) : ");
lab1.proyektor = Console.ReadLine().ToLower().Trim();
//AC
Console.Write("Ada AC? (true/false) : ");
lab1.ac = Console.ReadLine().ToLower().Trim();
//internet
Console.Write("Ada Internet (true/false) : ");
lab1.internet = Console.ReadLine().ToLower().Trim();
Console.WriteLine();
Console.Clear();
Console.WriteLine("Proyektor : Ada");
}
else
{
if (lab.internet == "true")
{
Console.WriteLine("internet : Ada");
}
else
{
Console.WriteLine("Proyektor : Ada");
}
else
{
if (lab1.ac == "true")
{
Console.WriteLine("AC : Ada");
}
else
{
if (lab1.internet == "true")
{
Console.WriteLine("internet : Ada");
}
else
{
struct nilai1
{
}
struct siswa
{
public int nim,nt,np,naf;
public string nama;
public nilai1 nilait;
public nilai1 nilaip;
}
static void Main(string[] args)
{
siswa s;
double nt = 0,np=0,naf=0;
Console.Write("Masukan NIM : ");
s.nim = int.Parse(Console.ReadLine());
Console.Write("Masukan Nama : ");
s.nama = Console.ReadLine();
//teory
Console.Write("Masukan nilai tugas Teory : ");
s.nilait.tugas = int.Parse(Console.ReadLine());
Console.Write("Masukan nilai UTS Teory : ");
s.nilait.uts = int.Parse(Console.ReadLine());
Console.Write("Masukan nilai UAS Teory : ");
s.nilait.uas = int.Parse(Console.ReadLine());
//praktek
Console.Write("Masukan nilai tugas Praktek : ");
s.nilaip.tugas = int.Parse(Console.ReadLine());
Console.Write("Masukan nilai UTS Praktek : ");
s.nilaip.uts = int.Parse(Console.ReadLine());
Console.Write("Masukan nilai UAS Praktek : ");
s.nilaip.uas = int.Parse(Console.ReadLine());
Console.Clear();
Console.ReadKey();
}
enum jabatan1
{
director=1, manager, supervisor, staff
}
struct dkaryawan
{
public string nama;
public int gajipokok, honorlembur, jamlembur, jumlahhonorlembur,
total,jabatan;
}
Console.Clear();
Console.WriteLine("PT.ABC");
Console.WriteLine("================================================");
Console.WriteLine("Nama Karyawan : " + kar.nama);
switch(jab)
{
case jabatan1.director:
Console.WriteLine("Jabatan : " + jabatan1.director);
Console.WriteLine("Gaji Pokok : Rp.50,000.000.00");
Console.WriteLine("Honor Lembur Per Jam : Rp.200,000.00");
Console.WriteLine("Lama Lembur : " + kar.jamlembur);
jumlahhonorlembur = kar.jamlembur * 200000;
Console.WriteLine("Jumlah Honor Lembur : " +
jumlahhonorlembur.ToString("Rp,#,##0.00"));
Console.WriteLine("================================================");
total = 50000000 + jumlahhonorlembur;
Console.WriteLine("Total : " +
total.ToString("Rp,#,##0.00"));
break;
case jabatan1.manager:
Console.WriteLine("Jabatan : " + jabatan1.manager);
Console.WriteLine("Gaji Pokok : Rp.25,000.000.00");
Console.WriteLine("Honor Lembur Per Jam : Rp.150,000.00");
Console.WriteLine("Lama Lembur : " + kar.jamlembur);
jumlahhonorlembur = kar.jamlembur * 150000;
Console.WriteLine("Jumlah Honor Lembur : " +
jumlahhonorlembur.ToString("Rp,#,##0.00"));
Console.WriteLine("================================================");
total = 25000000 + jumlahhonorlembur;
Console.WriteLine("Total : " +
total.ToString("Rp,#,##0.00"));
break;
case jabatan1.supervisor:
Console.WriteLine("Jabatan : " +
jabatan1.supervisor);
Console.WriteLine("Gaji Pokok : Rp.10,000.000.00");
Console.WriteLine("Honor Lembur Per Jam : Rp.100,000.00");
Console.WriteLine("Lama Lembur : " + kar.jamlembur);
jumlahhonorlembur = kar.jamlembur * 100000;
Console.WriteLine("Jumlah Honor Lembur : " +
jumlahhonorlembur.ToString("Rp,#,##0.00"));
Console.WriteLine("================================================");
total = 10000000 + jumlahhonorlembur;
Console.WriteLine("Total : " +
total.ToString("Rp,#,##0.00"));
break;
case jabatan1.staff:
Console.WriteLine("Jabatan : " + jabatan1.staff);
Console.WriteLine("Gaji Pokok : Rp.5,000.000.00");
Console.WriteLine("Honor Lembur Per Jam : Rp.80,000.00");
Console.WriteLine("Lama Lembur : " + kar.jamlembur);
jumlahhonorlembur = kar.jamlembur * 80000;
Console.WriteLine("Jumlah Honor Lembur : " +
jumlahhonorlembur.ToString("Rp,#,##0.00"));
Console.WriteLine("================================================");
total = 5000000 + jumlahhonorlembur;
Console.WriteLine("Total : " +
total.ToString("Rp,#,##0.00"));
break;
default:
Console.Write("Inputan Tidak Valid ! ");
break;
}
Console.ReadKey();
}
enum bulan
{
january=1,february,maret,april,mei,juni,july,agustust,september,oktober,november,desember
}
enum maskapai
{
Lion=1,Garuda,Sriwijaya,Citilink
}
enum rute
{
jakarta=1,bandung
}
struct tanggallahir
{
public int lahirtgl, lahirbln, lahirthn;
}
struct tanggalbrangkat
{
public int brangkattgl, brangkatbln, brangkatthn;
}
struct identitas
{
public string nama;
public int maskapai, rute, jumlahtiket, total;
public tanggallahir lahir;
public tanggalbrangkat brangkat;
}
static void Main(string[] args)
{
identitas iden;
bulan bln,bln1;
maskapai msk;
rute r;
Console.Write("Masukan Nama Pembeli : ");
iden.nama = Console.ReadLine();
//Brangkat
Console.Write("Masukan Tanggal Berangkat : ");
iden.brangkat.brangkattgl = int.Parse(Console.ReadLine());
//maskapai
Console.WriteLine("Maskapai");
Console.WriteLine("1.Lion");
Console.WriteLine("2.Garuda");
Console.WriteLine("3.Sriwijaya");
Console.WriteLine("4.CityLink");
Console.Write("Masukan Kode Maskapai : ");
iden.maskapai = int.Parse(Console.ReadLine());
msk = (maskapai)iden.maskapai;
//Rute
Console.WriteLine("Rute");
Console.WriteLine("1.Jakarta");
Console.WriteLine("2.Bandung");
Console.Write("Masukan kode rute : ");
iden.rute = int.Parse(Console.ReadLine());
r = (rute)iden.rute;
Console.Clear();
//LION
if(iden.maskapai == 1)
{
if(iden.rute == 1)
{
Console.WriteLine("Harga Tiket : Rp 600,000.00");
iden.total = 600000 * iden.jumlahtiket;
Console.WriteLine("Jumlah tiket : " + iden.jumlahtiket);
Console.WriteLine("Total : " + iden.total.ToString("Rp
#,##0.00"));
}
else if(iden.rute == 2)
{
Console.WriteLine("Harga Tiket : Rp 800,000.00");
iden.total = 800000 * iden.jumlahtiket;
Console.WriteLine("Jumlah tiket : " + iden.jumlahtiket);
Console.WriteLine("Total : " + iden.total.ToString("Rp
#,##0.00"));
}
else
{
Console.WriteLine("Inputan Tidak Valid !!! ");
}
}
//GARUDA
else if (iden.maskapai == 2)
{
if (iden.rute == 1)
{
Console.WriteLine("Harga Tiket : Rp 1,000,000.00");
iden.total = 1000000 * iden.jumlahtiket;
Console.WriteLine("Jumlah tiket : " + iden.jumlahtiket);
Console.WriteLine("Total : " + iden.total.ToString("Rp
#,##0.00"));
}
else if (iden.rute == 2)
{
Console.WriteLine("Harga Tiket : Rp 1,200,000.00");
iden.total = 1200000 * iden.jumlahtiket;
Console.WriteLine("Jumlah tiket : " + iden.jumlahtiket);
Console.WriteLine("Total : " + iden.total.ToString("Rp
#,##0.00"));
}
else
{
Console.WriteLine("Inputan Tidak Valid !!! ");
}
}
//SRIWIJAYA
else if (iden.maskapai == 3)
{
if (iden.rute == 1)
{
Console.WriteLine("Harga Tiket : Rp 750,000.00");
iden.total = 750000 * iden.jumlahtiket;
Console.WriteLine("Jumlah tiket : " + iden.jumlahtiket);
Console.WriteLine("Total : " + iden.total.ToString("Rp
#,##0.00"));
}
else if (iden.rute == 2)
{
Console.WriteLine("Harga Tiket : Rp 950,000.00");
iden.total = 950000 * iden.jumlahtiket;
Console.WriteLine("Jumlah tiket : " + iden.jumlahtiket);
Console.WriteLine("Total : " + iden.total.ToString("Rp
#,##0.00"));
}
else
{
Console.WriteLine("Inputan Tidak Valid !!! ");
}
}
//CityLink
else if (iden.maskapai == 4)
{
if (iden.rute == 1)
{
Console.WriteLine("Harga Tiket : Rp 650,000.00");
iden.total = 650000 * iden.jumlahtiket;
Console.WriteLine("Jumlah tiket : " + iden.jumlahtiket);
Console.WriteLine("Total : " + iden.total.ToString("Rp
#,##0.00"));
}
else if (iden.rute == 2)
{
Console.WriteLine("Harga Tiket : Rp 850,000.00");
iden.total = 850000 * iden.jumlahtiket;
Console.WriteLine("Jumlah tiket : " + iden.jumlahtiket);
Console.WriteLine("Total : " + iden.total.ToString("Rp
#,##0.00"));
}
else
{
Console.WriteLine("Inputan Tidak Valid !!! ");
}
}
else
{
Console.WriteLine("Inputan Tidak Valid !!! ");
}
Console.ReadKey();
}
1. Buatlah enumerasi dengan tipe Bulan dimana enumeratornya berisi nama-nama bulan dari
Januari sampai Desember. Kemudian minta user untuk memasukkan kode 1 sampai 12 untuk
menampilkan nama bulan berdasarkan kode yang dimasukkan!
enum bulan
{
januari=1,february,maret,april,mei,juni,july,agustust,september,oktober,november,desem
ber
}
Console.ReadKey();
2. Buatlah enumerasi dengan tipe Temperature dimana enumeratornya terdiri dari High, Medium,
dan Low. Jika user memilih:
Console.WriteLine("1.High");
Console.WriteLine("2.Medium");
Console.WriteLine("3.Low");
Console.Write("Pilih Temperature : ");
temp1 = int.Parse(Console.ReadLine());
temp = (temperaturea)temp1;
switch(temp)
{
case temperaturea.High:
Console.WriteLine("Masaklah ayam ini selama 1 Jam !");
break;
case temperaturea.Medium:
Console.WriteLine("Masaklah ayam ini selama 3 Jam !");
break;
case temperaturea.Low:
Console.WriteLine("Masaklah ayam ini selama 6 Jam !");
break;
default:
Console.WriteLine("Inputan Tidak Valid !!!");
break;
}
Console.ReadKey();
3. Buatlah data mahasiswa yang berisi NIM, nama, jurusan dan jenis kelamin dengan menggunakan
struktur. Buat pula jurusan (TI, SI, MN, AK, MI) dan jenis kelamin (Pria, Wanita) dengan
menggunakan enumerasi. Setelah data diinput, tampilkan hasilnya!
enum jk
{
Pria=1,Wanita
}
enum js
{
TI=1,SI,MN,AK,MI
}
struct mahasiswa1
{
public string nama;
public int nim;
}
static void Main(string[] args)
{
mahasiswa1 maha;
js jus;
jk jen;
int jk, js;
Console.Write("Nim : ");
maha.nim =int.Parse(Console.ReadLine());
Console.Write("Nama : ");
maha.nama = Console.ReadLine();
Console.WriteLine();
Console.WriteLine("1.Pria");
Console.WriteLine("2.Wanita");
Console.Write("Jenis Kelamin[1/2] : ");
jk = int.Parse(Console.ReadLine());
jen = (jk)jk;
Console.WriteLine();
Console.WriteLine("1.TI");
Console.WriteLine("2.SI");
Console.WriteLine("3.MN");
Console.WriteLine("4.AK");
Console.WriteLine("5.MI");
Console.Write("Jurusan [1/2/3/4/5] : ");
js = int.Parse(Console.ReadLine());
jus = (js)js;
Console.Clear();
Console.WriteLine("NIM {0} Nama {1} Jenis Kelamin {2} Jurususan {3}",
maha.nim, maha.nama, jen, jus);
Console.ReadKey();
}
UNIT 7 (Array)
for(int b = 0;b<a;b++)
{
Console.Write("Masukan nama ke - {0} = ", b + 1);
nama[b] = Console.ReadLine();
}
Console.Clear();
Console.WriteLine(" DAFTAR NAMA");
Console.WriteLine("=======================");
for(int b=0;b< a;b++)
{
Console.WriteLine("{0}. {1}", b + 1, nama[b]);
}
Console.ReadKey();
}
for(b=0;b<9;b++)
{
Console.Write("Masukan Angka ke-{0} : ", b + 1);
kode[b] = int.Parse(Console.ReadLine());
}
for(b=0;b<9;b++)
{
Console.Write(kode[b] + "=");
for(c=0;c<kode[b];c++)
{
Console.Write(pola1);
}
Console.WriteLine();
}
Console.ReadKey();
}
struct perbedaan
{
public int gg;
public string ganjil, genap;
}
static void garis()
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(new String('=', 30));
Console.ResetColor();
}
static void Main(string[] args)
{
perbedaan prb;
int a, b, c,ganjil=0,genap=0;
Console.Write("Masukan Jumlah Bilangan : ");
prb.gg = int.Parse(Console.ReadLine());
for (b=0;b<prb.gg;b++)
{
}
Console.Clear();
Console.Write("Angka\t Keterangan");
Console.WriteLine();
garis();
for(b=0;b<prb.gg;b++)
{
Console.Write(angka[b]);
for (c=0;c<1;c++)
{
if(angka[b] % 2 == 0)
{
genap++;
Console.Write("\t Genap");
}
else
{
ganjil++;
Console.Write("\t Ganjil");
}
}
Console.WriteLine();
}
Console.Write("Jumlah Bilangna Genap = {0}", genap);
Console.Write("\nJumlah Bilangan Ganjil = " + ganjil);
Console.ReadKey();
}
static void Main(string[] args)
{
int a, b, c, d;
for(b=0;b< a;b++)
{
Console.Write("Angka ke - {0} : ", b + 1);
angka[b] = int.Parse(Console.ReadLine());
}
Console.Clear();
Console.ReadKey();
}
static void garis()
{
for (a=0;a<3;a++)
{
}
}
Console.Write("Hasil Penjualan\n");
garis();
Console.WriteLine();
Console.Write("|Produk |Kuartal1\t|Kuartal2\t|Kuartal3\t|Kuartal4\n");
for (a = 0; a <3; a++)
{
Console.Write("\n{0}",a+1);
for (b = 0; b < 4; b++)
{
Console.Write("\t"+"|"+produk[a,b]+"\t");
}
}
Console.ReadKey();
}
static void Main(string[] args)
{
int[][] jagged = new int[3][];
int choice;
for(int row=0;row<jagged.Length;row++)
{
Console.Write("Masukan Jumlah Siswa kelas - {0} : " ,row+1);
choice = int.Parse(Console.ReadLine());
jagged[row] = new int[choice];
for(int col = 0;col<jagged[row].Length;col++)
{
Console.Write("Masukan Nilai Siswa ke - {0} : ", col + 1);
jagged[row][col] = int.Parse(Console.ReadLine());
}
Console.WriteLine();
}
Console.ReadKey();
1. Buatlah sebuah program untuk menyimpan dan menampilkan data mahasiswa berupa NIM,
Nama, Tanggal Lahir, dan Alamat. Data mahasiswa di-input melalui keyboard dengan n
sebagai banyaknya mahasiswa.
Console.WriteLine();
}
Console.WriteLine("Tekan Asal2");
Console.ReadLine();
Console.Clear();
Console.WriteLine("========================================================");
for (b=0;b < a; b++)
{
Console.Write(nim[b]);
Console.Write(" "+nama[b]);
Console.Write(" " + tanggal[b]);
Console.Write(" " + kelas[b]);
}
Console.WriteLine();
Console.WriteLine("========================================================");
Console.ReadKey();
}
2. Buatlah sebuah program untuk menyimpan dan menampilkan data mahasiswa berupa NIM,
Nama, Jurusan, dan Kelas. Jurusan didapatkan melalui kode jurusan yang terdapat di
NIM mahasiswa yang di-input. Data mahasiswa di-input melalui keyboard dengan n
sebagai banyaknya mahasiswa.
Console.WriteLine();
}
Console.WriteLine("Tekan Asal2");
Console.ReadLine();
Console.Clear();
for (b = 0; b < a; b++)
{
switch (kode[b])
{
case "111":
Console.WriteLine("Nama : " + nama[b]);
Console.WriteLine("Nim : " + nim[b]);
Console.WriteLine("Kelas : " + kelas[b]);
Console.WriteLine("Jurusan : Teknik Informatika");
break;
case "211":
Console.WriteLine("Nama : " + nama[b]);
Console.WriteLine("Nim : " + nim[b]);
Console.WriteLine("Kelas : " + kelas[b]);
Console.WriteLine("Jurusan : Sistem Informasi");
break;
case "311":
Console.WriteLine("Nama : " + nama[b]);
Console.WriteLine("Nim : " + nim[b]);
Console.WriteLine("Kelas : " + kelas[b]);
Console.WriteLine("Jurusan : Manajemen Informatika");
break;
case "411":
Console.WriteLine("Nama : " + nama[b]);
Console.WriteLine("Nim : " + nim[b]);
Console.WriteLine("Kelas : " + kelas[b]);
Console.WriteLine("Jurusan : Manajemen Bisnis");
break;
case "511":
Console.WriteLine("Nama : " + nama[b]);
Console.WriteLine("Nim : " + nim[b]);
Console.WriteLine("Kelas : " + kelas[b]);
Console.WriteLine("Jurusan : Akuntansi Perpajakan");
break;
default:
Console.WriteLine("Nama : " + nama[b]);
Console.WriteLine("Nim : " + nim[b]);
Console.WriteLine("Kelas : " + kelas[b]);
Console.WriteLine("Jurusan : Tidak Valid !!!");
break;
}
}
Console.ReadKey();
}
3. Buatlah sebuah program untuk menghitung rata-rata suhu udara selama seminggu
dimana suhu setiap harinya di-input oleh user melalui keyboard.
enum hari
{
senin,selasa,rabuu,kamis,jumat,sabtu,minggu
}
int a = 7, b, c = 0, d,e;
int[] suhu = new int[a];
h = (hari)b;
Console.Write("Suhu Hari {0} \t : ",h);
suhu[b] = int.Parse(Console.ReadLine());
c = c + suhu[b];
}
d = c / a;
Console.Clear();
for(b=0; b < a; b ++)
{
h = (hari)b;
Console.WriteLine("Suhu Pada Hari {1} Tercatat \t : {0} ",suhu[b],h
);
}
Console.WriteLine();
Console.WriteLine("Total Suhu Dalam 1 Minggu : " + c);
Console.WriteLine("Rata-Rata Suhu Dalam 1 Minggu : " + d);
Console.ReadKey();
4. Buatlah sebuah program untuk menghitung nilai huruf dari sekumpulan mahasiswa yang
datanya disimpan ke dalam sebuah array. Data yang di-input adalah NIM, Nama, UTS, Tugas,
UAS. Data mahasiswa di-input melalui keyboard dengan n sebagai banyaknya mahasiswa.
for(b=0;b <a;b++)
{
Console.Write("NIM : ");
nim[b] = int.Parse(Console.ReadLine());
Console.Write("Nama : ");
nama[b] = Console.ReadLine();
Console.Write("UTS : ");
uts[b] = int.Parse(Console.ReadLine());
Console.Write("Tugas : ");
tugas[b] = int.Parse(Console.ReadLine());
Console.Write("UAS : ");
uas[b] = int.Parse(Console.ReadLine());
for(b=0;b<a;b++)
{
if(total[b] > 90 && total[b] <= 100)
{
Console.WriteLine("NIM : " + nim[b]);
Console.WriteLine("Nama : " + nama[b]);
Console.WriteLine("UTS : " + uts[b]);
Console.WriteLine("Tugas : " + tugas[b]);
Console.WriteLine("UAS : " + uas[b]);
Console.WriteLine("Huruf Akhir : A");
Console.WriteLine();
}
Console.ReadKey();
}
static void Main(string[] args)
{
int a, b, c, d, e;
Char pola1;
for(b=0;b<9;b++)
{
Console.Write("Masukan Angka ke-{0} : ", b + 1);
kode[b] = int.Parse(Console.ReadLine());
}
for(b=0;b<9;b++)
{
Console.Write(kode[b] + "=");
for(c=0;c<kode[b];c++)
{
Console.Write(pola1);
}
Console.WriteLine();
}
Console.ReadKey();
}
static void Main(string[] args)
{
int a, b, c, d;
int[,] tipe1 = new int[3, 3];
int[,] tipe2 = new int[3, 3];
int[,] total = new int[3, 3];
for(a=0;a<3;a++)
{
for(b=0;b<3;b++)
{
Console.Write("Masukan Nilai Data 1{0} , {1} : ",a, b);
tipe1[a,b] = int.Parse(Console.ReadLine());
}
}
Console.WriteLine();
Console.ReadKey();
}
static void Main(string[] args)
{
int a, b;
double c;
string nama="joko",nama2="susi";
for(b=0;b< a; b++)
{
Console.Write("Masukan Nama : ");
nama1[b] = Console.ReadLine();
else if (nama1[b].Contains(nama2))
{
c = harga[b] * 0.17;
jumlah[b] = harga[b] - c;
Console.Write(nama1[b] + "\t" + harga[b] + "\t" + "17%\t" +
jumlah[b]);
}
else
{
c = harga[b] * 0.08;
jumlah[b] = harga[b] - c;
Console.Write(nama1[b] + "\t" + harga[b] + "\t" + "8%\t" +
jumlah[b]);
}
Console.WriteLine();
}
Console.ReadKey();
}
static void Main(string[] args)
{
Console.Write("Sudut\t Sin\t Cos\t Tan\t\n");
Console.WriteLine("=======================================");
for (int a=0;a<=360;a+=10)
{
Console.Write(a + "\t");
Console.Write(Math.Sin(a*Math.PI/180).ToString("0.00\t"));
Console.Write(Math.Cos(a * Math.PI / 180).ToString("0.00\t"));
Console.Write(Math.Tan(a * Math.PI / 180).ToString("0.00\t"));
Console.WriteLine();
}
Console.ReadKey();
}
static void Main(string[] args)
{
int a, b = 0, c, d, e, l, total, benar = 0;
double nilai;
Console.Write(" = ");
soal[c] = int.Parse(Console.ReadLine());
if (soal[c] == total)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Benar!");
Console.ResetColor();
benar++;
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Salah!");
Console.ResetColor();
}
Console.WriteLine();
}
}
Console.Write("Benar = {0} dari {1} soal\n",benar, a);
int selesai = (int)Math.Round((double)(100 * benar) / a);
Console.Write("Persentase = {0} % ",selesai);
Console.WriteLine();
Console.ReadKey();
}
Console.Write("Bulan :\t");
month = Console.ReadLine();
Console.Write("Hari :\t");
day = Console.ReadLine();
Console.Write("Tahun :\t");
year = Console.ReadLine();
Console.ReadKey();
}
Console.Clear();
Console.WriteLine("Format Penanggalan [Hari]/[Bulan]/[Tahun]");
Console.WriteLine("Tanggal Peminjaman = {0} / {1} / {2} ", hari, bulan,
tahun);
Console.WriteLine("Lama Peminjaman");
Console.WriteLine("1.15 Hari");
Console.WriteLine("2.1 Bulan");
Console.WriteLine("3.3 Bulan");
Console.WriteLine("4.6 Bulan");
Console.WriteLine("5.1 Tahun");
Console.Write("Masukan lama peminjaman [1-5] : ");
peminjaman = int.Parse(Console.ReadLine());
}
else if(peminjaman == 2)
{
var hariH = date.AddMonths(1).ToString("dd MMMM yyyy");
Console.Write("Tanggal Jatuh Tempo = {0}", hariH);
}
else if (peminjaman == 3)
{
var hariH = date.AddMonths(3).ToString("dd MMMM yyyy");
Console.Write("Tanggal Jatuh Tempo = {0}", hariH);
}
else if (peminjaman == 4)
{
var hariH = date.AddMonths(6).ToString("dd MMMM yyyy");
Console.Write("Tanggal Jatuh Tempo = {0}", hariH);
}
else if (peminjaman == 5)
{
var hariH = date.AddYears(1).ToString("dd MMMM yyyy");
Console.Write("Tanggal Jatuh Tempo = {0}", hariH);
}
else
{
Console.Write("Inputan Tidak Valid !!! ");
}
Console.ReadKey();
}
x:
Console.WriteLine();
garis();
Console.WriteLine(" Menu ");
garis();
Console.WriteLine("1. Celcius => Reamur");
Console.WriteLine("2. Celcius => Fahrenheit");
Console.WriteLine("3. Celcius => Kelvin");
garis();
Console.Write("Masukan kode [1-3] : ");
a = int.Parse(Console.ReadLine());
if (a == 1)
{
Console.Clear();
Console.Write("Masukan suhu Celcius : ");
suhu = int.Parse(Console.ReadLine());
total = reamur() * suhu;
Console.Write("Konversi dari suhu {0} Celcius = {1} suhu Reamur",
suhu, total);
}
else if (a == 2)
{
Console.Write("Masukan suhu Celcius : ");
suhu = int.Parse(Console.ReadLine());
total = fahrenheit() * suhu + 32;
Console.Write("Konversi dari suhu {0} Celcius = {1} suhu Fahrenheit",
suhu, total.ToString("."));
}
else if (a == 3)
{
Console.Write("Masukan suhu Celcius : ");
suhu = int.Parse(Console.ReadLine());
total = kelvin() + suhu;
Console.Write("Konversi dari suhu {0} Celcius = {1} suhu Kelvin",
suhu, total.ToString("."));
}
else
{
Console.Clear();
Console.Write("Inputan Tidak Valid !!! ");
}
goto x;
Console.ReadKey();
}
Console.Write(d+"\t");
}
}
else
{
Console.Write("Batas awal harus lebih kecil dari batas akhir.");
}
}
static void turun1()
{
int a, b, c, d;
Console.WriteLine();
garis();
Console.Write("Menu");
Console.WriteLine();
garis();
naik();
turun();
Console.WriteLine();
garis();
Console.Write("Masukan Kode [1/2] : ");
a = int.Parse(Console.ReadLine());
Console.Clear();
if(a==1)
{
naik1();
}
else if(a==2)
{
turun1();
}
else
{
Console.Clear();
Console.Write("Inputan Tidak Valid !!!");
}
goto x;
Console.ReadKey();
}
Console.Clear();
Console.WriteLine("Saldo awal = {0}", a.ToString("Rp."));
garis();
Console.WriteLine();
for(d=1;d<=c;d++)
{
Console.Write("Bulan Ke - {0} : ", d );
lama2=lama1(d);
for(e=0;e<1; e++)
{
persen2 = persen1(b);
total2 = (double)a * persen2 * lama2;
semua2 = (double)a + total2;
Console.Write("\t{0}", semua2.ToString("Rp #,##0"));
akhir[e] = total2;
}
Console.WriteLine();
}
garis();
for (d = 0; d < 1; d++)
{
Console.WriteLine();
Console.ReadKey();
}
static void ubah(ref int a,ref int b,ref int c,ref int d)
{
c = a;
d = b;
}
static void Main(string[] args)
{
int a, b, c,d;
c = a;
d = b;
Console.WriteLine("Sebelum Proses:");
Console.WriteLine("Bilangan 1 : {0}", a);
Console.WriteLine("Bilangan 2 : {0}", b);
Console.WriteLine();
ubah(ref a, ref b,ref c,ref d);
Console.WriteLine("Sesudah Proses:");
Console.WriteLine("Bilangan 1 : {0}", d);
Console.WriteLine("Bilangan 2 : {0}", c);
Console.ReadKey();
}
static int[] simpan;
static int hilang;
int a, b;
}
Console.Clear();
Console.WriteLine("Tampilan Data : ");
for (b = 0; b < a; b++)
{
Console.Write(array1[b]+"\t");
}
simpan = array1;
hilang = a;
return array1;
}
if (a == 1)
{
Array.Sort(simpan);
Console.WriteLine("Ascending - Tampilan Data : ");
foreach (int element in simpan)
{
Console.Write(element + " ");
}
}
else if(a == 2)
{
Array.Reverse(simpan);
Console.WriteLine("Descending - Tampilan Data : ");
foreach(int element in simpan)
{
Console.Write(element + " ");
}
}
else
{
Console.Clear();
Console.Write("Inputan Tidak Valid!!!");
}
return a;
}
Console.Clear();
int a;
Console.Write("Masukan Angka yang dicari : ");
a = int.Parse(Console.ReadLine());
Console.Write("{0} ditemukan pada indeks = {1}", a, Array.IndexOf(simpan,a));
return a;
}
arr.Remove(a);
foreach(int element in arr)
{
Console.Write(element + " ");
}
return a;
}
static int pilihan5()
{
Console.Clear();
int a = 0;
Console.Write("Tampilan Data : ");
Console.WriteLine();
Array.Clear(simpan,0,hilang);
return a;
}
static void Main(string[] args)
{
int a;
x:
Console.WriteLine();
Console.WriteLine("Menu");
Console.WriteLine("============================");
Console.WriteLine("1.Input Angka ");
Console.WriteLine("2.Urutkan Angka ");
Console.WriteLine("3.Cari Angka ");
Console.WriteLine("4.Hapus 1 Angka ");
Console.WriteLine("5.Hapus Semua");
Console.WriteLine("============================");
Console.Write("Masukan Kode [1-5] : ");
a = int.Parse(Console.ReadLine());
if (a == 1)
{
pilihan1();
}
else if (a == 2)
{
pilihan2();
}
else if (a == 3)
{
pilihan3();
}
else if(a == 4)
{
pilihan4();
}
else if(a==5)
{
pilihan5();
}
else
{
Console.Clear();
Console.Write("Inputan Tidak Valid!!!");
}
goto x;
Console.ReadKey();
}
static string [] nama;
static int[] nim;
static double[] uts;
static double []uas;
static double[] tugas;
static int jumlah;
static double [] jumlahnilai;
static int[] nilaimm;
}
static void garis1()
{
Console.ForegroundColor = ConsoleColor.Green;
Console.Write(new string('=', 80));
Console.ResetColor();
}
static void pilihan1()
{
int a;
Console.Clear();
garis();
Console.WriteLine();
Console.Write(" INPUT DATA ");
Console.WriteLine();
garis();
Console.WriteLine();
for (int b = 0; b < a; b++)
{
}
nama = nama1;
nim = nim1;
tugas = tugas1;
uts = uts1;
uas = uas1;
jumlah = a;
jumlahnilai = njumlah;
nilaimm = nilaim;
}
static void pilihan2()
{
Console.Clear();
garis1();
Console.Write("\t"+"A"+"\n");
}
else if (nilaimm[b]>=71 && nilaimm[b]<=85)
{
}
Console.WriteLine();
garis1();
}
static void pilihan3()
{
Array.Clear(nama, 0, jumlah);
Array.Clear(nim, 0, jumlah);
Array.Clear(tugas, 0, jumlah);
Array.Clear(uts, 0, jumlah);
Array.Clear(uas, 0, jumlah);
Array.Clear(jumlahnilai, 0, jumlah);
Console.Clear();
garis1();
Console.WriteLine(" HAPUS DATA");
garis1();
Console.Write("Data berhasil dihapus");
}
static void Main(string[] args)
{
int a;
do {
x:
Console.WriteLine();
garis();
Console.WriteLine();
Console.Write(" MENU ");
Console.WriteLine();
garis();
Console.WriteLine();
Console.WriteLine("1. Input Data");
Console.WriteLine("2. Tampil Data");
Console.WriteLine("3. Hapus Data");
Console.WriteLine("4. Keluar");
garis();
Console.WriteLine();
Console.Write("Masukan Kode [1-4] : ");
a = int.Parse(Console.ReadLine());
if (a == 1)
{
pilihan1();
}
else if (a == 2)
{
pilihan2();
}
else if (a == 3)
{
pilihan3();
}
else if (a == 4)
{
Console.Write("Terima Kasih,...");
Console.ReadKey();
}
else
{
Console.Clear();
Console.Write("Inputan Tidak Valid !!!");
goto x;
}
} while(a == 1 | a==2 |a==3);
if (n > r)
{
for (b = 1; b <= n; b++)
{
c *= b;
}
d = n - r;
for (b = 1; b <= d; b++)
{
e *= b;
}
total = c / e;
Console.Write("{0}P{1} = {2}", n, r, total);
}
else
{
Console.Write("Nilai R tidak boleh lebih besar dari nilai n.");
}
return n;
}
if (n > r)
{
for (b = 1; b <= n; b++)
{
c *= b;
}
for(b=1;b<=r;b++)
{
d *= b;
}
kurang = n - r;
for (b = 1; b <= kurang; b++)
{
e *= b;
}
totalR = d * e;
total = c / totalR;
Console.Write("{0}P{1} = {2}", n, r, total);
}
else
{
Console.Write("Nilai R tidak boleh lebih besar dari nilai n.");
}
return n;
}
static void Main(string[] args)
{
int a;
x:
Console.WriteLine();
Console.WriteLine("1.Permutasi");
Console.WriteLine("2.Kombinasi");
Console.Write("Masukan Kode [1-2] : ");
a = int.Parse(Console.ReadLine());
if(a==1)
{
pilihan1();
}
else if(a==2)
{
pilihan2();
}
else
{
Console.Clear();
Console.Write("Inputan Tidak Valid !!! ");
}
goto x;
Console.ReadKey();
}
}
static double nilaipi()
{
return (double)22 / 7;
}
static int pilihan1()
{
Console.Clear();
int a;
Console.WriteLine(" BOLA ");
garis();
Console.Write("Masukan jari - jari : ");
a = int.Parse(Console.ReadLine());
garis();
luas = 4 * nilaipi() *a *a;
volume = 4 / 3 * nilaipi();
jari2 = a * a * a;
jarivol = volume * jari2;
volume = nilaipi()*a* a;
jarivol = volume * b;
d = a * b;
e = a * c;
f = b * c;
luas = 2 * (d + e + f);
volume = a * b *c ;
x:
Console.WriteLine();
garis();
Console.WriteLine(" Menu");
garis();
Console.WriteLine("1.Bola");
Console.WriteLine("2.Tabung");
Console.WriteLine("3.Kubus");
Console.WriteLine("4.Balok");
garis();
Console.Write("Masukan Kode [1/2/3/4] : ");
a = int.Parse(Console.ReadLine());
if(a == 1)
{
pilihan1();
}
else if(a == 2)
{
pilihan2();
}
else if(a == 3)
{
pilihan3();
}
else if(a == 4)
{
pilihan4();
}
else
{
Console.Clear();
Console.Write("Inputan Tidak Valid !!! ");
}
goto x;
Console.ReadKey();
}