Last active
April 11, 2018 16:38
-
-
Save way2datta/90492dcf08ac21b136e3c4d22976e9c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace Assignment | |
{ | |
internal class Program | |
{ | |
private static Dictionary<string, int> CGR = new Dictionary<string, int>(); | |
private static Dictionary<string, string> iCat = new Dictionary<string, string>(); | |
private static void Main(string[] args) | |
{ | |
CGR.Add("Food-grains", 0); | |
CGR.Add("Furniture", 5); | |
CGR.Add("Electronics", 18); | |
CGR.Add("Cosmetics", 28); | |
iCat.Add("Rice", "Food-grains"); | |
iCat.Add("Wheat", "Food-grains"); | |
iCat.Add("Sofa", "Furniture"); | |
iCat.Add("Chairs", "Furniture"); | |
iCat.Add("TV", "Electronics"); | |
iCat.Add("Mobile", "Electronics"); | |
iCat.Add("Shampoo", "Cosmetics"); | |
iCat.Add("Perfume", "Cosmetics"); | |
Console.WriteLine("Welcome to NMart store"); | |
Console.WriteLine("***************************"); | |
Console.Write("Enter name of item: "); | |
string iName = Console.ReadLine(); | |
Console.Write("Enter quantity of item: "); | |
int iQnt = int.Parse(Console.ReadLine()); | |
Console.Write("Enter rate per product item: "); | |
int iRate = int.Parse(Console.ReadLine()); | |
string cName = ""; | |
foreach (var cat in iCat) | |
{ | |
if (cat.Key == iName) | |
{ | |
cName = cat.Value; | |
break; | |
} | |
} | |
int cPercentage = 0; | |
foreach (var c in CGR) | |
{ | |
if (c.Key == cName) | |
{ | |
cPercentage = c.Value; | |
break; | |
} | |
} | |
double fPrice = iQnt * (iRate + iRate * cPercentage / 100.0); | |
string output = "*******************************************\n" + | |
"Billing Details for " + iName + ":\n" + | |
"*******************************************\n" + | |
"Quantity: " + iQnt + | |
"\nPrice per unit: " + iRate + | |
"\nFinal rate: " + fPrice; | |
Console.WriteLine(output); | |
Console.WriteLine("\n*********************************\n"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment