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 HOA3_12Car_Daguman
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> iname = new List<string>();
- List<double> iprice = new List<double>();
- Console.WriteLine("GROCERY CHECKOUT SIM");
- Console.WriteLine("");
- Console.WriteLine("Choose an Option");
- Console.WriteLine("");
- Console.WriteLine("[A] Scan Item");
- Console.WriteLine("[B] Show Receipt");
- Console.WriteLine("");
- Console.Write("Enter Choice: ");
- string choice = Console.ReadLine();
- string stop = "n";
- while(stop == "n")
- {
- if (choice == "A" || choice == "a" || choice == "Scan Item")
- {
- Console.Clear();
- Console.WriteLine("Scan Item - Grocery Checkout Sim");
- Console.WriteLine("");
- Console.Write("Enter Item Name: ");
- iname.Add(Console.ReadLine());
- Console.Write("Enter Item Price ($): ");
- iprice.Add(double.Parse(Console.ReadLine()));
- Console.WriteLine("");
- Console.WriteLine("Item Added!");
- Console.WriteLine("");
- Console.Write("Done Adding Items? (y/n): ");
- stop = Console.ReadLine();
- }
- else if (choice == "B" || choice == "b" || choice == "Show Receipt")
- {
- Console.Clear();
- Console.WriteLine("Receipt - GROCERY CHECKOUT SIM");
- Console.WriteLine("");
- Console.WriteLine("NAME PRICE($)");
- for (int i = 0; i < iname.Count; i++)
- {
- Console.WriteLine(iname[i] + " " + iprice[i]);
- }
- Console.WriteLine("");
- double total = iprice.Sum();
- Console.Write("Total Price ($): " +total);
- Console.WriteLine("");
- Console.Write("Done checking Out? (y/n): ");
- stop = Console.ReadLine();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement