Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MarketPlace
- {
- public class Program
- {
- public class myReverserClass : IComparer
- {
- int IComparer.Compare(Object mProduct, Object mPrice)
- {
- return ((new CaseInsensitiveComparer()).Compare(mProduct, mPrice));
- }
- static void Main(string[] args)
- {
- Console.Write("How many product you will buy : ");
- int n = int.Parse(Console.ReadLine());
- string[] mProduct = new string[n];
- double[] mPrice = new double[n];
- for (int i = 0; i < mProduct.Length; i++)
- {
- Console.Write("Enter your product :");
- mProduct[i] = Console.ReadLine();
- }
- for (int j = 0; j < mPrice.Length; j++)
- {
- Console.Write("Enter your price :");
- mPrice[j] = double.Parse(Console.ReadLine());
- }
- Console.WriteLine("1 for Product sort Or 2 for price sort :");
- int choice = int.Parse(Console.ReadLine());
- switch (choice)
- {
- case 1:
- Array.Sort(mProduct);
- Console.WriteLine("Product sort :");
- PrintProductsAndPrices(mProduct, mPrice);
- break;
- case 2:
- Array.Sort(mPrice);
- Console.WriteLine("Price sort:");
- PrintProductsAndPrices(mProduct, mPrice);
- break;
- Console.WriteLine();
- }
- }
- private static void PrintProductsAndPrices(string[] mProduct, double[] mPrice)
- {
- for (int i = 0; i < mProduct.Length; i++)
- {
- Console.WriteLine(" {0,-10}: {1}", mProduct[i], mPrice[i]);
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement