diff --git a/CashRegister/CashRegister.sln b/CashRegister/CashRegister.sln new file mode 100644 index 00000000..552f5fa4 --- /dev/null +++ b/CashRegister/CashRegister.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.902 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CashRegister", "CashRegister\CashRegister.csproj", "{B1530C03-3E17-4F02-860C-8DCAC32552FB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B1530C03-3E17-4F02-860C-8DCAC32552FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B1530C03-3E17-4F02-860C-8DCAC32552FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B1530C03-3E17-4F02-860C-8DCAC32552FB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B1530C03-3E17-4F02-860C-8DCAC32552FB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8C0CC773-9382-4040-8047-EA3EEB4CFF98} + EndGlobalSection +EndGlobal diff --git a/CashRegister/CashRegister/App.config b/CashRegister/CashRegister/App.config new file mode 100644 index 00000000..00bfd114 --- /dev/null +++ b/CashRegister/CashRegister/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CashRegister/CashRegister/CashRegister.csproj b/CashRegister/CashRegister/CashRegister.csproj new file mode 100644 index 00000000..67ed4ed7 --- /dev/null +++ b/CashRegister/CashRegister/CashRegister.csproj @@ -0,0 +1,66 @@ + + + + + Debug + AnyCPU + {B1530C03-3E17-4F02-860C-8DCAC32552FB} + Exe + CashRegister + CashRegister + v4.6.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CashRegister/CashRegister/CashRegister.csproj.user b/CashRegister/CashRegister/CashRegister.csproj.user new file mode 100644 index 00000000..2f196a36 --- /dev/null +++ b/CashRegister/CashRegister/CashRegister.csproj.user @@ -0,0 +1,6 @@ + + + + ShowAllFiles + + \ No newline at end of file diff --git a/CashRegister/CashRegister/Model/Transcation.cs b/CashRegister/CashRegister/Model/Transcation.cs new file mode 100644 index 00000000..986d2c20 --- /dev/null +++ b/CashRegister/CashRegister/Model/Transcation.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CashRegister.Model +{ + public class TranscationModel + { + public int Payment { get; set; } + public int Purchase { get; set; } + } +} diff --git a/CashRegister/CashRegister/Program.cs b/CashRegister/CashRegister/Program.cs new file mode 100644 index 00000000..0413afac --- /dev/null +++ b/CashRegister/CashRegister/Program.cs @@ -0,0 +1,91 @@ +using CashRegister.Model; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CashRegister +{ + class Program + { + public static void Main(string[] args) + { + CashRegisterApp(); + } + + + + + public static void CashRegisterApp() + { + List trans = new List(); + string fileName = "transcations.txt"; + string filePath = Path.Combine(Environment.CurrentDirectory, @"TranscationFile\", fileName); + + using (var reader = new StreamReader(filePath)) + { + while (!reader.EndOfStream) + { + var line = reader.ReadLine(); + var values = line.Split(','); + int pur = Convert.ToInt32(values[0].Replace(".", "")); + int pay = Convert.ToInt32(values[1].Replace(".", "")); + trans.Add(new TranscationModel { Payment = pay, Purchase= pur }); + } + } + + foreach (var tran in trans) + { + int payment = tran.Payment; //$5.00 + int purchase = tran.Purchase; //$2.68 + int change = payment - purchase; + int changeincents = change * 100; + bool israndom = (changeincents % 3) == 0; + + if (change == 0) + { + Console.WriteLine("No Change to be dispensed"); + } + + if (change < 0) + { + Console.WriteLine("Insufficient Funds"); + } + + else if (israndom == true && changeincents > 0) + { + + Random random = new Random(); + decimal ranchange = change; + + var denoms = new[] { // ordered + new { name = "dollar", nominal = 100m }, + new { name = "quarter", nominal = 0.25m }, + new { name = "dime", nominal = 0.10m }, + new { name = "nickel", nominal = 0.05m }, + new { name = "pennies", nominal = 0.01m } + }; + + Console.WriteLine("Your random change is " + random.Next(3) + " dollar(s) " + random.Next(3) + " quarter(s) " + random.Next(3) + " dime(s) " + random.Next(3) + " nickle(s) " + random.Next(3) + " and " + random.Next(3) + " penn(ies)"); + + + } + else if (changeincents > 0) + { + int dollars = change / 100; + change = change % 100; + int quarters = change / 25; + change = change % 25; + int dimes = change / 10; + change = change % 10; + int nickles = change / 5; + int pennies = change % 1; + Console.WriteLine("Your change is " + dollars + " dollar(s) " + quarters + " quarter(s) " + dimes + " dime(s) " + nickles + " nickle(s), and " + pennies + " pennie(s)."); + } + } + Console.ReadLine(); + } + } +} diff --git a/CashRegister/CashRegister/Properties/AssemblyInfo.cs b/CashRegister/CashRegister/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..9d85d86e --- /dev/null +++ b/CashRegister/CashRegister/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CashRegister")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CashRegister")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b1530c03-3e17-4f02-860c-8dcac32552fb")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/CashRegister/CashRegister/bin/Debug/CashRegister.exe b/CashRegister/CashRegister/bin/Debug/CashRegister.exe new file mode 100644 index 00000000..7c9c72e7 Binary files /dev/null and b/CashRegister/CashRegister/bin/Debug/CashRegister.exe differ diff --git a/CashRegister/CashRegister/bin/Debug/CashRegister.exe.config b/CashRegister/CashRegister/bin/Debug/CashRegister.exe.config new file mode 100644 index 00000000..00bfd114 --- /dev/null +++ b/CashRegister/CashRegister/bin/Debug/CashRegister.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CashRegister/CashRegister/bin/Debug/CashRegister.pdb b/CashRegister/CashRegister/bin/Debug/CashRegister.pdb new file mode 100644 index 00000000..4a1a5dba Binary files /dev/null and b/CashRegister/CashRegister/bin/Debug/CashRegister.pdb differ diff --git a/CashRegister/CashRegister/bin/Debug/TranscationFile/transcations.txt b/CashRegister/CashRegister/bin/Debug/TranscationFile/transcations.txt new file mode 100644 index 00000000..83007530 --- /dev/null +++ b/CashRegister/CashRegister/bin/Debug/TranscationFile/transcations.txt @@ -0,0 +1,5 @@ +2.12,3.00 +1.97,2.00 +3.33,5.00 +12.99, 12.99 +15.20, 15.00 \ No newline at end of file diff --git a/CashRegister/CashRegister/obj/Debug/CashRegister.csproj.CoreCompileInputs.cache b/CashRegister/CashRegister/obj/Debug/CashRegister.csproj.CoreCompileInputs.cache new file mode 100644 index 00000000..f3cb58f5 --- /dev/null +++ b/CashRegister/CashRegister/obj/Debug/CashRegister.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +cec696cedcc266259b3910b25ac5456a17346403 diff --git a/CashRegister/CashRegister/obj/Debug/CashRegister.csproj.FileListAbsolute.txt b/CashRegister/CashRegister/obj/Debug/CashRegister.csproj.FileListAbsolute.txt new file mode 100644 index 00000000..63d8a310 --- /dev/null +++ b/CashRegister/CashRegister/obj/Debug/CashRegister.csproj.FileListAbsolute.txt @@ -0,0 +1,14 @@ +C:\Users\umufti\source\repos\CashRegister\CashRegister\bin\Debug\CashRegister.exe.config +C:\Users\umufti\source\repos\CashRegister\CashRegister\bin\Debug\CashRegister.exe +C:\Users\umufti\source\repos\CashRegister\CashRegister\bin\Debug\CashRegister.pdb +C:\Users\umufti\source\repos\CashRegister\CashRegister\obj\Debug\CashRegister.csprojAssemblyReference.cache +C:\Users\umufti\source\repos\CashRegister\CashRegister\obj\Debug\CashRegister.csproj.CoreCompileInputs.cache +C:\Users\umufti\source\repos\CashRegister\CashRegister\obj\Debug\CashRegister.exe +C:\Users\umufti\source\repos\CashRegister\CashRegister\obj\Debug\CashRegister.pdb +C:\Users\pkumar\Documents\CashRegister\CashRegister\CashRegister\bin\Debug\CashRegister.exe.config +C:\Users\pkumar\Documents\CashRegister\CashRegister\CashRegister\bin\Debug\CashRegister.exe +C:\Users\pkumar\Documents\CashRegister\CashRegister\CashRegister\bin\Debug\CashRegister.pdb +C:\Users\pkumar\Documents\CashRegister\CashRegister\CashRegister\obj\Debug\CashRegister.csprojAssemblyReference.cache +C:\Users\pkumar\Documents\CashRegister\CashRegister\CashRegister\obj\Debug\CashRegister.csproj.CoreCompileInputs.cache +C:\Users\pkumar\Documents\CashRegister\CashRegister\CashRegister\obj\Debug\CashRegister.exe +C:\Users\pkumar\Documents\CashRegister\CashRegister\CashRegister\obj\Debug\CashRegister.pdb diff --git a/CashRegister/CashRegister/obj/Debug/CashRegister.csprojAssemblyReference.cache b/CashRegister/CashRegister/obj/Debug/CashRegister.csprojAssemblyReference.cache new file mode 100644 index 00000000..1603845a Binary files /dev/null and b/CashRegister/CashRegister/obj/Debug/CashRegister.csprojAssemblyReference.cache differ diff --git a/CashRegister/CashRegister/obj/Debug/CashRegister.exe b/CashRegister/CashRegister/obj/Debug/CashRegister.exe new file mode 100644 index 00000000..7c9c72e7 Binary files /dev/null and b/CashRegister/CashRegister/obj/Debug/CashRegister.exe differ diff --git a/CashRegister/CashRegister/obj/Debug/CashRegister.pdb b/CashRegister/CashRegister/obj/Debug/CashRegister.pdb new file mode 100644 index 00000000..4a1a5dba Binary files /dev/null and b/CashRegister/CashRegister/obj/Debug/CashRegister.pdb differ diff --git a/CashRegister/CashRegister/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/CashRegister/CashRegister/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 00000000..faa019b0 Binary files /dev/null and b/CashRegister/CashRegister/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ