Senin, 13 Desember 2010

Tugas kuliah "Program untuk penjualan Counter menggunakan C#"

namespace tian
{
      class Program
      {
            public static void Main(string[] args)
            {
                  string jenisPulsa;
                  int deposit;
                  int depositTambah;
                  int pulsaDibeli;
                  int pulsaJual;
                  int hargaPulsa = 0;
                  int laba = 0;
                  string noHp;
                  string tanyaUlang = "";
           
                 
                  //user interface
                  Console.WriteLine("   Program Cellular Pulsa All Oprator");
                  Console.WriteLine("   ----------------------------------");
                  Console.WriteLine();
                 
                  //input
                  Console.Write("Deposit Awal : Rp. ");
                  deposit = Convert.ToInt32(Console.ReadLine());
                  Console.WriteLine();
                  Console.WriteLine("   Transaksi PHAI_ZO CELL");
                  Console.WriteLine("   ---------------------");
                  do
                  {
                 
                  Console.WriteLine();
                  Console.Write("Jenis pulsa yang dibeli : ");
                  jenisPulsa=Console.ReadLine();
                  Console.Write("Masukkan nomer HP       : ");
                  noHp=Console.ReadLine();
                  Console.Write("Besar pulsa yang dibeli : Rp. ");
                  pulsaDibeli = Convert.ToInt32(Console.ReadLine());
                 
                  //Seleksi harga pulsa
                  if (pulsaDibeli<=25000)
                  { pulsaJual=pulsaDibeli+1000;}                       
                  else {pulsaJual=pulsaDibeli+500;}
                 
                  //Seleksi operator
                  switch (jenisPulsa)
                  {
                        case "AS" :
                              hargaPulsa = pulsaJual;
                              break;
                        case "SIMPATI" :
                              hargaPulsa = pulsaJual + 500;
                              break;
                        case "XL" :
                              hargaPulsa = pulsaJual - 500;
                              break;
                        case "IM3" :
                              if ( pulsaJual >= 25000)
                              {
                                    hargaPulsa = pulsaJual - 500;
                              }
                              else {hargaPulsa = pulsaJual - 1000;}
                              break;
                        case "MENTARI" :
                              hargaPulsa = pulsaJual + 1000;
                              break;
                  }
                 
                  //Proses
                  Console.WriteLine();
                  deposit = deposit - pulsaDibeli;
                  laba = laba + (hargaPulsa - pulsaDibeli);
                 
                  //seleksi sisa deposit
                  if (deposit < pulsaDibeli)
                  {
                        Console.WriteLine("Maaf deposit pulsa anda tidak mencukupi transaksi ini");
                        Console.Write("Masukkan tambahan depoosit : Rp. ");
                        depositTambah = Convert.ToInt32(Console.ReadLine());
                        deposit = deposit + depositTambah;
                        Console.WriteLine();
                  }
                       
                  //Output
                  Console.WriteLine("harga jual   : Rp. {0}",
                                   hargaPulsa.ToString());
                  Console.WriteLine("Deposit sisa : Rp. {0} ",
                                   deposit.ToString());
                  Console.WriteLine("-----------------------------");
                  Console.WriteLine();
                  Console.Write("Apakah ada transaksi lagi? [Y/T] : ");
                  tanyaUlang = Console.ReadLine();
                  }
                  while(tanyaUlang.ToLower() == "y");
                 
                  Console.WriteLine();
                  Console.WriteLine("------------------------------");
                  Console.WriteLine("Sisa deposit : Rp {0}",deposit);
                  Console.WriteLine("Keuntungan   : Rp {0}",laba);
                  Console.WriteLine("------------------------------");
                  Console.WriteLine();
           
                  Console.Write("Press any key to continue . . . ");
                  Console.ReadKey(true);
            }
      }
}

0 komentar:

Posting Komentar

About Me

Foto Saya
Tian | Blog's
Banyuwangi, Jawa Timur, Indonesia
gak keren tapi menarik, kadang jutek tapi baik, :D
Lihat profil lengkapku
Tian Septian 15 Desember jam 16:11 Laporkan
widget