ALPRO

ARRAY 2


namespace
 {
 class Program
 {
 static void Main(string[] args)
 {
 //Variabel
 byte jmlhBaris = 0;
 byte jmlhKolom = 0;

//Deklarasi
 byte[,] matrixA;
 byte[,] matrixB;

//input jmlh baris dan kolom

Console.Write("Masukkan Jumlah Elemen Baris = ");
 jmlhBaris = Convert.ToByte(Console.ReadLine());
 Console.Write("Masukkan Jumlah Elemen Kolom = ");
 jmlhKolom = Convert.ToByte(Console.ReadLine());

//inisialisai array
 matrixA = new byte[jmlhBaris, jmlhKolom];
 matrixB = new byte[jmlhBaris, jmlhKolom];

//mengisi array

Console.WriteLine("         Masukkan Nilai Matrix    A");

for (byte a = 0; a < 1; a++) //matrik
 {

for (byte baris = 0; baris < jmlhBaris; baris++)
 {

for (byte kolom = 0; kolom < jmlhKolom; kolom++)
 {
 //isi array per elemen

Console.Write("matrixA[{0},{1}] = ", baris.ToString(), kolom.ToString());
 matrixA[baris, kolom] = Convert.ToByte(Console.ReadLine());

}
 }
 }
 //tampilkan elemen array

for (byte baris = 0; baris < jmlhBaris; baris++)
 {
 for (byte kolom = 0; kolom < jmlhKolom; kolom++)
 {
 if (baris == 0)
 {
 matrixB[baris, kolom] = Convert.ToByte(matrixA[baris, kolom] + 0);
 }
 else
 {
 matrixB[baris, kolom] = Convert.ToByte(matrixA[baris, kolom] + matrixA[baris - 1, kolom]);
 }
 }

}

//elemen output
 Console.WriteLine();
 Console.WriteLine("Menampilkan Hasil Nilai Matrix    B");
 /*
 for (byte baris = 0; baris < jmlhBaris; baris++)
 {
 for (byte kolom = 0; kolom < jmlhKolom; kolom++)
 {
 Console.WriteLine("Output elemen matrixB ke[{0},{1}]={2}", baris, kolom, matrixB[baris, kolom]);
 }
 }
 */

Console.WriteLine();
 Console.WriteLine();
 Console.WriteLine("    A              B");
 Console.WriteLine();
 for (byte baris = 0; baris < jmlhBaris; baris++)
 {
 if (baris == 0)
 {
 Console.WriteLine("-        -     -        -");
 Console.Write("|");
 }
 else if (baris == jmlhBaris - 1)
 {
 Console.Write("|");
 }
 else
 Console.Write("|");

for (byte kolom = 0; kolom < jmlhKolom; kolom++)
 {
 Console.Write(" {0}  ", matrixA[baris, kolom]);
 }
 if (baris == (jmlhBaris / 2))
 Console.Write("|  =  |");
 else
 Console.Write("|     |");
 for (byte kolom = 0; kolom < jmlhKolom; kolom++)
 {
 Console.Write(" {0}  ", matrixB[baris, kolom]);
 }

if (baris == 0)
 {
 Console.WriteLine("|");
 }
 else if (baris == jmlhBaris - 1)
 {
 Console.WriteLine("|");
 Console.Write("-        -     -        -");
 }
 else
 Console.WriteLine("|");

}

Console.ReadLine();
 }
 }
 }

PROGRAM HARGA


namespace Tugas_Alpro_2
 {
 class Program
 {
 static void Main(string[] args)
 {
 //deklarasi
 string ulang;
 int banyakelemen;
 int tot=0;

//deklarasi object
 string [] barang;
 int [] harga;
 byte [] qty;
 int [] subtot;

//input array

do
 {
 Console.Clear();

try
 {
 Console.ForegroundColor = ConsoleColor.Magenta;
 Console.Write("masukkan jumlah barang ");
 banyakelemen = Convert.ToInt32(Console.ReadLine());

//inisialisasi
 Console.ForegroundColor = ConsoleColor.Red;
 barang = new string[banyakelemen];
 harga = new int[banyakelemen];
 qty = new byte[banyakelemen];
 subtot = new int[banyakelemen];

//input
 Console.ForegroundColor = ConsoleColor.Blue;
 for (byte i = 0; i < banyakelemen; i++)
 {
 Console.SetCursorPosition(0, (i + 2));
 Console.WriteLine("|");

Console.SetCursorPosition(0, (i + 3));
 Console.WriteLine("|");

Console.SetCursorPosition(0, (i + 4));
 Console.WriteLine("|");

Console.SetCursorPosition(20, (i + 2));
 Console.WriteLine("|");

Console.SetCursorPosition(20, (i + 3));
 Console.WriteLine("|");

Console.SetCursorPosition(20, (i + 4));
 Console.WriteLine("|");

Console.SetCursorPosition(40, (i + 2));
 Console.WriteLine("|");

Console.SetCursorPosition(40, (i + 3));
 Console.WriteLine("|");

Console.SetCursorPosition(40, (i + 4));
 Console.WriteLine("|");

Console.SetCursorPosition(60, (i + 2));
 Console.WriteLine("|");

Console.SetCursorPosition(60, (i + 3));
 Console.WriteLine("|");

Console.SetCursorPosition(60, (i + 4));
 Console.WriteLine("|");
 }

Console.SetCursorPosition(0, 1);
 Console.WriteLine("====================");

Console.SetCursorPosition(20, 1);
 Console.WriteLine("--------------------");

Console.SetCursorPosition(40, 1);
 Console.WriteLine("====================");

Console.SetCursorPosition(60, 1);
 Console.WriteLine("--------------------");

Console.SetCursorPosition(0, 3);
 Console.WriteLine("====================");

Console.SetCursorPosition(20, 3);
 Console.WriteLine("--------------------");

Console.SetCursorPosition(40, 3);
 Console.WriteLine("====================");

Console.SetCursorPosition(60, 3);
 Console.WriteLine("--------------------");

Console.SetCursorPosition(0, (banyakelemen + 4));
 Console.WriteLine("===========================");

Console.SetCursorPosition(1, 2);
 Console.WriteLine("    barang");

Console.SetCursorPosition(21, 2);
 Console.WriteLine("    harga");

Console.SetCursorPosition(41, 2);
 Console.WriteLine("    qty");

Console.SetCursorPosition(61, 2);
 Console.WriteLine("    subtotal");

Console.SetCursorPosition(45, (banyakelemen + 5));
 Console.WriteLine("Total = ");

for (byte i = 0; i < banyakelemen; i++)
 {
 Console.SetCursorPosition(1, (i + 4));
 barang[i] = Console.ReadLine();

Console.SetCursorPosition(21, (i + 4));
 harga[i] = Convert.ToInt32(Console.ReadLine());

Console.SetCursorPosition(41, (i + 4));
 qty[i] = Convert.ToByte(Console.ReadLine());

Console.SetCursorPosition(61, (i + 4));
 subtot[i] = Convert.ToInt32(harga[i] * qty[i]);
 Console.WriteLine(subtot[i]);

}

//proses
 Console.ForegroundColor = ConsoleColor.DarkRed;
 for (int i = 0; i < banyakelemen; i++)
 {
 tot = tot + subtot[i];
 }

//output

Console.ForegroundColor = ConsoleColor.Green;
 Console.SetCursorPosition(60, (banyakelemen + 5));
 Console.WriteLine(tot);

}

catch (Exception)
 {

Console.WriteLine("inputan yang anda masukkan salah");
 }

Console.WriteLine(" ulang ? ");
 ulang=Console.ReadLine();

}

while (ulang=="y" || ulang=="Y");

Console.ReadKey(true);
 }
 }
 }

PROGRAM BESARAN DETIK

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace tugas_alpro_2
{
class Program
{
static void Main(string[] args)
{
//Deklarasi

int jumlahdetik ;
int jam;
int menit ;
int detik ;

//Judul
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine("                    ===========================\a");
Console.WriteLine("                 Menghitung Besaran Jam Menit Detik  ");
Console.WriteLine("                    ===========================");

//Input
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("                    ===========================");
Console.Write("Masukkan Besaran jumlah detik = ");
jumlahdetik = Convert.ToInt32(Console.ReadLine());

//Proses
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("                    ===========================\a");
jam = (jumlahdetik / 3600);
menit = (jumlahdetik % 3600) / 60;
detik = (jumlahdetik % 3600) % 60;

//output
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("                     ==========================\a");
Console.WriteLine("Hasil Penghitungan jam = {0} ", jam);
Console.WriteLine("Hasil Penghitungan menit = {0} ",menit);
Console.WriteLine("Hasil Penghitungan detik = {0} ",detik);

Console.ReadKey(true);
Console.ReadLine();

}
}
}

PROGRAM GAJI

</p>
namespace tugas_praktikum_2
 {
 class Program
 {
 static void Main(string[] args)
 {
 const int Gajiperhari = 95000;

byte jamkerja;
 int gajibulanan;

Console.WriteLine("                ================================");
 Console.WriteLine("                Program Menghitung Gaji Karyawan");
 Console.WriteLine("                ================================");

Console.Write(" masukkan jam kerja anda selama 1 bulan = ");
 jamkerja = Convert.ToByte(Console.ReadLine());

if (jamkerja <= 25)
 {
 if (jamkerja <= 17)
 {
 gajibulanan = (95000 * jamkerja) - ((20 - jamkerja) * 95000);
 }

else if (jamkerja <= 19)
 {
 gajibulanan = 95000 * jamkerja;
 }

else if (jamkerja > 20)
 {
 gajibulanan = (95000 * 20) + ((jamkerja - 20) * (3 * 95000));
 }
 else
 {
 gajibulanan = (95000 * jamkerja) + (95000 * 2);
 }

Console.WriteLine("gaji selama 1 bulan anda  ={0}", gajibulanan.ToString());
 }
 else
 {
 Console.WriteLine("Sory,your nominal false.please try agains!");
 }

Console.WriteLine("Press any key to continue . . . ");
 Console.ReadKey(true);
 }
 }
 }

PROGRAM PERHITUNGAN REKENING AIR

 class Program
 {
 public static void Main(string[] args)
 {
 //deklarasi
 int awal, akhir, penggunaan, total, pakai1, pakai2, pakai3, pakai4, pakai5, sisa1, sisa2, sisa3, byr1, byr2, byr3, byr4, byr5, denda, bayar, kembalian, adm;
 byte tgl;
 string ulang;
 //pemberian nilai awal
 pakai1=pakai2=pakai3=pakai4=pakai5=0;
 sisa1=sisa2=sisa3=0;
 adm=2500;
 const int h1=500;
 const int h2=550;
 const int h3=600;
 const int h4=700;
 const int h5=800;</p>
do
 {

Console.WriteLine("        PROGRAM MENGHITUNG JUMLAH TAGIHAN REKENING AIR");
 Console.WriteLine("                                                                            ");
 Console.WriteLine("Informasi harga air :");

Console.WriteLine("pemakaian 10 m3 Ke-1      =    Rp 500");
 Console.WriteLine("pemakaian 10 m3 Ke-2      =    Rp 550");
 Console.WriteLine("pemakaian 10 m3 Ke-3      =    Rp 600");
 Console.WriteLine("pemakaian 10 m3 Ke-4      =    Rp 700");
 Console.WriteLine("pemakaian air Ke-5 >40 m3 =    Rp 800");
 Console.WriteLine("Pembayaran jatuh tempo tgl 20, jika terlambat denda Rp 6000");
 Console.WriteLine("                                                                            ");

//input
 Console.Write("Masukkan meter awal        = ");
 awal=Convert.ToInt32(Console.ReadLine());
 Console.Write("Masukkan meter akhir        = ");
 akhir=Convert.ToInt32(Console.ReadLine());
 Console.Write("Tanggal pembayaran        : ");
 tgl=Convert.ToByte(Console.ReadLine());

//PROSES
 penggunaan=akhir-awal;

//denda
 if(tgl>20)
 {
 denda=6000;
 }
 else
 denda=0;

//menghitung air

//10 pertama
 if(penggunaan>10)
 {
 pakai1=10;
 sisa1=penggunaan-10;
 }
 else
 pakai1=penggunaan;

//10 kedua
 if(sisa1>10)
 {
 pakai2=10;
 sisa2=sisa1-10;
 }
 else
 pakai2=sisa1;

//10 ketiga
 if(sisa2>10)
 {
 pakai3=10;
 sisa3=sisa2-10;
 }
 else
 pakai3=sisa2;

//10 keempat
 if(sisa3>10)
 {
 pakai4=10;
 pakai5=sisa3-10;
 }
 else
 pakai4=sisa3;

//total harga
 byr1=pakai1*h1;
 byr2=pakai2*h2;
 byr3=pakai3*h3;
 byr4=pakai4*h4;
 byr5=pakai5*h5;
 total=byr5+byr4+byr3+byr2+byr1+denda+adm;

//output
 Console.WriteLine("Total pemakaian air anda bulan ini            =    "+penggunaan+" m3");
 Console.WriteLine("                                                                            ");
 Console.WriteLine("Dengan rincian sbb");

Console.WriteLine("************************************************************");
 Console.WriteLine("    Rincian        *    Besar pemakaian (m3)    *    Harga*");
 Console.WriteLine("***********************************************************");
 Console.Write("pemakaian 10 m3 Ke-1    *        " +pakai1);
 Console.WriteLine("        * Rp     "+byr1+"    ||");
 Console.Write("pemakaian 10 m3 Ke-2    *        " +pakai2);
 Console.WriteLine("        * Rp     "+byr2+"    ||");
 Console.Write("pemakaian 10 m3 Ke-3    *        " +pakai3);
 Console.WriteLine("        * Rp     "+byr3+"    ||");
 Console.Write("pemakaian 10 m3 Ke-4    *        " +pakai4);
 Console.WriteLine("        * Rp     "+byr4+"    ||");
 Console.Write("pemakaian >40m3        *        " +pakai5);
 Console.WriteLine("        * Rp    "+byr5+"    ||");
 Console.Write("denda            *        ");
 Console.WriteLine("        * Rp    "+denda+"    ||");
 Console.Write("Administrasi        *        ");
 Console.WriteLine("        * Rp    "+adm+"    ||");
 Console.WriteLine("*************************************************************");
 Console.WriteLine("                                                           ||");
 Console.WriteLine("        TOTAL yang harus dibayar        * Rp    "+total+"  ||");
 Console.WriteLine("                                                           ||");
 Console.WriteLine("*************************************************************");
 Console.Write("        BAYAR                    = Rp    ");
 bayar=Convert.ToInt32(Console.ReadLine());
 kembalian=bayar-total;
 Console.WriteLine("        Kembalian                = Rp    "+kembalian);
 Console.Write("                                                                 ");

Console.WriteLine("        TERIMAKASIH TELAH MELAKUKAN PEMBAYARAN");
 Console.WriteLine("             SENYUM PELANGGAN SENYUM KAMI");
 Console.WriteLine("                                                              ");
 Console.WriteLine("_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ");
 Console.Write("apakah diulang ? (Y(y) / N)    :");
 ulang=Convert.ToString(Console.ReadLine());

}
 while(ulang=="Y"|ulang=="y");

Console.Write("MATUR NUWUN...........NGGIHHH...... ");
 Console.ReadKey(true);
 }
 }
 }

 

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s