Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp4
- {
- class Program
- {
- static barang[] brg = new barang[0];
- struct barang
- {
- public string Tipe;
- public int Harga;
- public int merek;
- public int Jenis;
- public int Jumlah;
- public int Qty;
- public int subtotal()
- {
- return Harga * Qty;
- }
- public enum elektronik
- {
- Kulkas = 1,
- Tv = 2,
- AC = 3,
- Microwave = 4,
- Smartphone = 5,
- }
- public enum mereks
- {
- Samsung = 1,
- sharp = 2,
- lg = 3,
- panasonic = 4,
- }
- static void input()
- {
- Array.Resize(ref brg, brg.Length + 1);
- Console.Clear();
- Console.WriteLine("===========================================");
- Console.WriteLine(" INPUT DATA ");
- Console.WriteLine("===========================================");
- Console.Write("Masukkan Jumlah elektronik : ");
- brg[brg.GetUpperBound(0)].Jumlah = int.Parse(Console.ReadLine());
- Console.WriteLine();
- Console.WriteLine("Jenis Elektronik : ");
- Console.WriteLine("1. Kulkas ");
- Console.WriteLine("2. TV ");
- Console.WriteLine("3. AC ");
- Console.WriteLine("4. Microwave ");
- Console.WriteLine("5. Smartphone ");
- Console.Write("Masukkan Jenis [1-5] : ");
- brg[brg.GetUpperBound(0)].Jenis = int.Parse(Console.ReadLine());
- Console.WriteLine("Merek : ");
- Console.WriteLine("1. Samsung ");
- Console.WriteLine("2. Sharp ");
- Console.WriteLine("3. LG ");
- Console.WriteLine("4. Panasonic ");
- Console.Write("Masukkan Merek [1-4] : ");
- brg[brg.GetUpperBound(0)].merek = int.Parse(Console.ReadLine());
- Console.Write("Masukkan Tipe : ");
- brg[brg.GetUpperBound(0)].Tipe = Console.ReadLine();
- Console.Write("Masukkan Harga : ");
- brg[brg.GetUpperBound(0)].Harga = int.Parse(Console.ReadLine());
- Console.Write("Masukkan Qty : ");
- brg[brg.GetUpperBound(0)].Qty = int.Parse(Console.ReadLine());
- }
- static void tampil()
- {
- Console.Clear();
- Console.Title = "Tampil";
- DateTime tgl = DateTime.Now;
- Console.WriteLine("============================================================================================");
- Console.WriteLine(" Jenis Merek Tipe Harga Qty Subtotal");
- Console.WriteLine("============================================================================================");
- foreach (barang data in brg)
- {
- Console.WriteLine( " "+ data.Jenis + data.merek + data.Tipe.PadRight(7) + data.Harga.ToString("0.000").PadRight(5) + data.Qty + data.subtotal().ToString("0.00"));
- }
- }
- static void Main(string[] args)
- {
- Console.Title = "Elektronik";
- int kode;
- ulang:
- Console.Clear();
- Console.WriteLine(" MENU ");
- Console.WriteLine("==================================================");
- Console.WriteLine("1. Input Data ");
- Console.WriteLine("2. Tampil Data ");
- Console.WriteLine("3. Input Keluar ");
- Console.WriteLine("==================================================");
- kode = int.Parse(Console.ReadLine());
- if (kode == 1)
- {
- input();
- }
- else
- if (kode == 2)
- {
- tampil();
- }
- else if (kode == 3)
- {
- Environment.Exit(0);
- }
- else
- {
- Console.WriteLine("Kode tidak valid.");
- }
- Console.ReadKey();
- goto ulang;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement