0% found this document useful (0 votes)
17 views3 pages

Kuis Algo

This C# program allows a user to manage product orders. It defines an enum for product types, a struct to store order details, and arrays to hold order data. The main menu allows adding/viewing orders or exiting. When adding an order, the user enters product, quantity and price details, which are stored in the order array. Order details can then be viewed in a formatted table, showing totals. The program loops, prompting after each action to add more orders or exit.

Uploaded by

Goklas Sitio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

Kuis Algo

This C# program allows a user to manage product orders. It defines an enum for product types, a struct to store order details, and arrays to hold order data. The main menu allows adding/viewing orders or exiting. When adding an order, the user enters product, quantity and price details, which are stored in the order array. Order details can then be viewed in a formatted table, showing totals. The program loops, prompting after each action to add more orders or exit.

Uploaded by

Goklas Sitio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

KUIS ALGO

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

namespace Kuis_algo
{
class Program
{
static int kode, bayar,i;
enum NamaBarang
{
Laptop = 1,Kulkas,Ac,Proyektor
}
struct Pemesanan
{
public NamaBarang Barang;
public int Jumlah;
public int Harga;
public double Subtotal;
}
static Pemesanan[] ukt = new Pemesanan[0];
static string konfirmasi = "";
static void Pertanyaan()
{
Console.Write("Apakah ingin Manambah Transaksi[Y/N]?");
konfirmasi = Console.ReadLine().ToLower();
}
static void pilihan2()
{
Console.Clear();
Console.WriteLine("NO.\tNama Barang\tJumlah\tHarga\tsubtotal");
Console.WriteLine(new string('=', 81));
for (int i = 0; i < ukt.Length; i++) ;
{
Console.WriteLine("{0}",(i + 1)+"\t"+ukt[i].Barang + "\t" + " untuk" +
ukt[i].Harga + "[Harga]" + "\t\t" + ukt[i].Jumlah.ToString("Rp #,##") + "" + "" +
ukt[i].Subtotal.ToString("Rp #,##"));

}
Console.WriteLine("\n" + new string('=', +81));
double total = 0;
for (int i = 0; i < ukt.Length; i++)
{
total += ukt[i].Subtotal;
}
Console.WriteLine("\n" + new string('=', 81));
Console.WriteLine("".PadRight(67) + DateTime.Today.ToString("dd/MM/yyyy"));
Pertanyaan();
}

static void Main(string[] args)


{
do
{
int u;
Console.Title = "Kuis";
no1:
Console.Clear();
Console.WriteLine(new string(' ', 17) + "=PILIH MENU =");
Console.WriteLine(new string('-', 50));
Console.WriteLine("1.Pesanan\n2.Tampilan Pemesanan\n3.Keluar Program");
Console.WriteLine(new string('-', 50));
Console.Write("Masukkan kode Menu[1-3]:");

kode = int.Parse(Console.ReadLine());
if (kode == 1)
{

Console.Clear();
Console.WriteLine(new string('=', 50));
Console.WriteLine(new string(' ', 15) + "Pesanan");
Console.WriteLine(new string('=', 50));
Console.Write("Masukkan Jumlah Barang:");
u = int.Parse(Console.ReadLine());

Array.Resize(ref ukt, ukt.Length + u);

Console.WriteLine();
for (int i = 0; i < u; i++)
{
Console.WriteLine("\nBarang Ke-{0}.", i + 1);
Console.WriteLine(new string('=', 50));
Console.WriteLine("Kode Barang:");
Console.WriteLine("1.Laptop\t2.Kulkas\t3.AC\t4.Proyektor");
Console.WriteLine();

Console.Write("Pilih Barang[1-4]: ");


ukt[i].Barang = (NamaBarang)int.Parse(Console.ReadLine());

Console.Write("Jumlah Barang:");
ukt[i].Jumlah = int.Parse(Console.ReadLine());

Console.Write("Harga Barang: ");


ukt[i].Harga = int.Parse(Console.ReadLine());

ukt[i].Subtotal = ukt[i].Harga * ukt[i].Jumlah;

}
Pertanyaan();

}
else if (kode == 2)
{
Console.Clear();
Console.WriteLine("no".PadRight(5) + "Barang".PadRight(10) +
"Harga".PadRight(10) + "Jumlah".PadLeft(5) + "subtotal".PadLeft(10));

Console.WriteLine(new string('=',80));

for (int i = 0; i < ukt.Length; i++)


{
Console.WriteLine((i + 1).ToString().PadRight(5) +
ukt[i].Barang.ToString().PadRight(5) + ukt[i].Jumlah.ToString().PadLeft(9) +
ukt[i].Subtotal.ToString().PadLeft(10));
}
Console.WriteLine(new string('=', 80));
Console.WriteLine("total".PadLeft(50));
Console.WriteLine(new string('=', 80));
Console.WriteLine("Tanggal.".PadLeft(50) +
DateTime.Today.ToString("MM/dd/yyyy").PadLeft(2));
Pertanyaan();
}
else if (kode == 3)
{
System.Environment.Exit(0);
}
else
{
Console.WriteLine("Tidak Valid,inputan Ulang!");
Console.ReadKey();
goto no1;
}
}
while (konfirmasi == "y");
Console.ReadKey();
}
}
}

You might also like