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 Assingment2SalesProgram
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.BackgroundColor = ConsoleColor.White;
- Console.WriteLine("Hello! This is simple login system!");
- Console.Write("Write your username here: ");
- string strUsername = Console.ReadLine();
- string strTUsername = "mason";
- if (strUsername == strTUsername)
- {
- Console.Write("Write your password here: ");
- string strPassword = Console.ReadLine();
- string strTPassword = "123";
- if (strPassword == strTPassword)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("You are logged in! Press Enter To Continue");
- Console.ReadLine();
- }
- else
- {
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.WriteLine("Bad password for user: {0}", strUsername);
- Console.ReadLine();
- }
- }
- else
- {
- Console.WriteLine("Bad username!");
- Console.ReadLine();
- }
- 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
- List<double> total = new List<double>() { 0, 0, 0, 0, 0, 0, 0 };
- List<double> profit = new List<double>() { 0, 0, 0, 0, 0, 0, 0 };
- int quantity = 0; // USER ENTER
- int userproductnum = 0; // USER ENTER
- Console.ForegroundColor = ConsoleColor.Red;
- Console.BackgroundColor = ConsoleColor.White;
- Console.WriteLine("Welcome to XYZ LTD\n");
- Console.WriteLine("=====================================\n");
- Console.WriteLine("\n");
- Console.WriteLine("==============Product Menu=============\n");
- Console.WriteLine("\n");
- Console.ForegroundColor = ConsoleColor.Black;
- Console.WriteLine("1.Product Retail Price 5.99\n");
- Console.WriteLine("2.Product Retail Price 2.99\n");
- Console.WriteLine("3.Product Retail Price 4.20\n");
- Console.WriteLine("4.Product Retail Price 1.99\n");
- Console.WriteLine("5.Product Retail Price 4.45\n");
- Console.WriteLine("6.Product Retail Price 3.30\n");
- Console.WriteLine("7.Product Retail Price 5.20\n");
- while (quantity != -1) // Stating while value does not equal -1 go to cases
- {
- Console.WriteLine("Please enter Quantity followed by Product Number ; OR Enter -1 to get totals oR Quit THE program");
- quantity = Convert.ToInt32(Console.ReadLine());
- if (quantity != -1) // Stating while value does not equal -1 go to cases
- {
- userproductnum = Convert.ToInt32(Console.ReadLine());
- switch (userproductnum)
- {
- case 1:
- total[0] += price.ElementAt(0) * quantity;
- break;
- case 2:
- total[1] += price.ElementAt(1) * quantity;
- break;
- case 3:
- total[2] += price.ElementAt(2) * quantity;
- break;
- case 4:
- total[3] += price.ElementAt(3) * quantity;
- break;
- case 5:
- total[4] += price.ElementAt(4) * quantity;
- break;
- case 6:
- total[5] += price.ElementAt(5) * quantity;
- break;
- case 7:
- total[6] += price.ElementAt(6) * quantity;
- break;// cases for each product
- default:
- Console.WriteLine("you have entered an incorrect product number.");// ERROR HANDELLING when product number is incorrect.
- break;
- }
- }
- }
- Console.WriteLine("total sales for product 1 are {0:C2}\n", total.ElementAt(0));
- Console.WriteLine("total profit for product 1 are {0:C2}\n", profit.ElementAt(0));
- Console.WriteLine("===========================\n");
- Console.WriteLine("total sales for product 2 are {0:C2}\n", total.ElementAt(1));
- Console.WriteLine("===========================\n");
- Console.WriteLine("total sales for product 3 are {0:C2}\n", total.ElementAt(2));
- Console.WriteLine("===========================\n");
- Console.WriteLine("total sales for product 4 are {0:C2}\n", total.ElementAt(3));
- Console.WriteLine("===========================\n");
- Console.WriteLine("total sales for product 5 are {0:C2}\n", total.ElementAt(4));
- Console.WriteLine("===========================\n");
- Console.WriteLine("total sales for product 6 are {0:C2}\n", total.ElementAt(5));
- Console.WriteLine("===========================\n");
- Console.WriteLine("total sales for product 7 are {0:C2}\n", total.ElementAt(6));
- Console.WriteLine("===========================\n");
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement