Advertisement
Guest User

Untitled

a guest
Jun 14th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.87 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 Assingment2SalesProgram
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.ForegroundColor = ConsoleColor.Red;
  14. Console.BackgroundColor = ConsoleColor.White;
  15. Console.WriteLine("Hello! This is simple login system!");
  16. Console.Write("Write your username here: ");
  17. string strUsername = Console.ReadLine();
  18. string strTUsername = "mason";
  19. if (strUsername == strTUsername)
  20. {
  21. Console.Write("Write your password here: ");
  22.  
  23. string strPassword = Console.ReadLine();
  24. string strTPassword = "123";
  25. if (strPassword == strTPassword)
  26. {
  27. Console.ForegroundColor = ConsoleColor.Red;
  28. Console.WriteLine("You are logged in! Press Enter To Continue");
  29. Console.ReadLine();
  30.  
  31. }
  32. else
  33. {
  34. Console.ForegroundColor = ConsoleColor.Gray;
  35. Console.WriteLine("Bad password for user: {0}", strUsername);
  36. Console.ReadLine();
  37. }
  38. }
  39. else
  40. {
  41. Console.WriteLine("Bad username!");
  42. Console.ReadLine();
  43. }
  44.  
  45.  
  46. List<double> price = new List<double>() { 5.99, 2.99, 4.20, 1.99, 4.45, 3.30, 5.20 }; //Declearing variable as a list
  47. List<double> total = new List<double>() { 0, 0, 0, 0, 0, 0, 0 };
  48. List<double> profit = new List<double>() { 0, 0, 0, 0, 0, 0, 0 };
  49. int quantity = 0; // USER ENTER
  50. int userproductnum = 0; // USER ENTER
  51.  
  52.  
  53. Console.ForegroundColor = ConsoleColor.Red;
  54. Console.BackgroundColor = ConsoleColor.White;
  55. Console.WriteLine("Welcome to XYZ LTD\n");
  56. Console.WriteLine("=====================================\n");
  57. Console.WriteLine("\n");
  58. Console.WriteLine("==============Product Menu=============\n");
  59. Console.WriteLine("\n");
  60. Console.ForegroundColor = ConsoleColor.Black;
  61. Console.WriteLine("1.Product Retail Price 5.99\n");
  62. Console.WriteLine("2.Product Retail Price 2.99\n");
  63. Console.WriteLine("3.Product Retail Price 4.20\n");
  64. Console.WriteLine("4.Product Retail Price 1.99\n");
  65. Console.WriteLine("5.Product Retail Price 4.45\n");
  66. Console.WriteLine("6.Product Retail Price 3.30\n");
  67. Console.WriteLine("7.Product Retail Price 5.20\n");
  68. while (quantity != -1) // Stating while value does not equal -1 go to cases
  69. {
  70.  
  71.  
  72.  
  73.  
  74. Console.WriteLine("Please enter Quantity followed by Product Number ; OR Enter -1 to get totals oR Quit THE program");
  75. quantity = Convert.ToInt32(Console.ReadLine());
  76.  
  77.  
  78.  
  79.  
  80.  
  81. if (quantity != -1) // Stating while value does not equal -1 go to cases
  82. {
  83.  
  84.  
  85.  
  86. userproductnum = Convert.ToInt32(Console.ReadLine());
  87.  
  88. switch (userproductnum)
  89. {
  90. case 1:
  91. total[0] += price.ElementAt(0) * quantity;
  92.  
  93. break;
  94.  
  95. case 2:
  96. total[1] += price.ElementAt(1) * quantity;
  97.  
  98. break;
  99. case 3:
  100. total[2] += price.ElementAt(2) * quantity;
  101.  
  102. break;
  103. case 4:
  104. total[3] += price.ElementAt(3) * quantity;
  105.  
  106. break;
  107. case 5:
  108. total[4] += price.ElementAt(4) * quantity;
  109.  
  110. break;
  111. case 6:
  112. total[5] += price.ElementAt(5) * quantity;
  113.  
  114. break;
  115. case 7:
  116. total[6] += price.ElementAt(6) * quantity;
  117.  
  118. break;// cases for each product
  119. default:
  120. Console.WriteLine("you have entered an incorrect product number.");// ERROR HANDELLING when product number is incorrect.
  121. break;
  122.  
  123. }
  124. }
  125.  
  126. }
  127.  
  128. Console.WriteLine("total sales for product 1 are {0:C2}\n", total.ElementAt(0));
  129.  
  130. Console.WriteLine("total profit for product 1 are {0:C2}\n", profit.ElementAt(0));
  131.  
  132. Console.WriteLine("===========================\n");
  133.  
  134. Console.WriteLine("total sales for product 2 are {0:C2}\n", total.ElementAt(1));
  135.  
  136. Console.WriteLine("===========================\n");
  137.  
  138. Console.WriteLine("total sales for product 3 are {0:C2}\n", total.ElementAt(2));
  139.  
  140. Console.WriteLine("===========================\n");
  141.  
  142. Console.WriteLine("total sales for product 4 are {0:C2}\n", total.ElementAt(3));
  143.  
  144. Console.WriteLine("===========================\n");
  145.  
  146. Console.WriteLine("total sales for product 5 are {0:C2}\n", total.ElementAt(4));
  147.  
  148. Console.WriteLine("===========================\n");
  149.  
  150. Console.WriteLine("total sales for product 6 are {0:C2}\n", total.ElementAt(5));
  151.  
  152. Console.WriteLine("===========================\n");
  153.  
  154. Console.WriteLine("total sales for product 7 are {0:C2}\n", total.ElementAt(6));
  155.  
  156. Console.WriteLine("===========================\n");
  157.  
  158. Console.ReadLine();
  159.  
  160.  
  161. }
  162. }
  163. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement