Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace HOA3_12Car_Daguman
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. List<string> iname = new List<string>();
  14. List<double> iprice = new List<double>();
  15.  
  16. Console.WriteLine("GROCERY CHECKOUT SIM");
  17. Console.WriteLine("");
  18. Console.WriteLine("Choose an Option");
  19. Console.WriteLine("");
  20. Console.WriteLine("[A] Scan Item");
  21. Console.WriteLine("[B] Show Receipt");
  22. Console.WriteLine("");
  23. Console.Write("Enter Choice: ");
  24. string choice = Console.ReadLine();
  25. string stop = "n";
  26.  
  27.  
  28. while(stop == "n")
  29. {
  30. if (choice == "A" || choice == "a" || choice == "Scan Item")
  31. {
  32. Console.Clear();
  33. Console.WriteLine("Scan Item - Grocery Checkout Sim");
  34. Console.WriteLine("");
  35. Console.Write("Enter Item Name: ");
  36. iname.Add(Console.ReadLine());
  37. Console.Write("Enter Item Price ($): ");
  38. iprice.Add(double.Parse(Console.ReadLine()));
  39. Console.WriteLine("");
  40. Console.WriteLine("Item Added!");
  41. Console.WriteLine("");
  42. Console.Write("Done Adding Items? (y/n): ");
  43. stop = Console.ReadLine();
  44.  
  45. }
  46. else if (choice == "B" || choice == "b" || choice == "Show Receipt")
  47. {
  48. Console.Clear();
  49. Console.WriteLine("Receipt - GROCERY CHECKOUT SIM");
  50. Console.WriteLine("");
  51. Console.WriteLine("NAME PRICE($)");
  52. for (int i = 0; i < iname.Count; i++)
  53. {
  54. Console.WriteLine(iname[i] + " " + iprice[i]);
  55. }
  56. Console.WriteLine("");
  57. double total = iprice.Sum();
  58. Console.Write("Total Price ($): " +total);
  59. Console.WriteLine("");
  60. Console.Write("Done checking Out? (y/n): ");
  61. stop = Console.ReadLine();
  62. }
  63.  
  64.  
  65. }
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement