diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b06e864 --- /dev/null +++ b/.gitignore @@ -0,0 +1,212 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Visual Studio 2015 cache/options directory +.vs/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +## TODO: Comment the next line if you want to checkin your +## web deploy settings but do note that will include unencrypted +## passwords +#*.pubxml + +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# LightSwitch generated files +GeneratedArtifacts/ +_Pvt_Extensions/ +ModelManifest.xml diff --git a/Assignment1.sln b/Assignment1.sln new file mode 100644 index 0000000..cf738b5 --- /dev/null +++ b/Assignment1.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assignment1", "Assignment1\Assignment1.csproj", "{27B52AB6-22BF-45BB-9007-BDBBCE58135D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {27B52AB6-22BF-45BB-9007-BDBBCE58135D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {27B52AB6-22BF-45BB-9007-BDBBCE58135D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {27B52AB6-22BF-45BB-9007-BDBBCE58135D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {27B52AB6-22BF-45BB-9007-BDBBCE58135D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Assignment1/App.config b/Assignment1/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/Assignment1/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Assignment1/Assignment1.csproj b/Assignment1/Assignment1.csproj new file mode 100644 index 0000000..37fa254 --- /dev/null +++ b/Assignment1/Assignment1.csproj @@ -0,0 +1,61 @@ + + + + + Debug + AnyCPU + {27B52AB6-22BF-45BB-9007-BDBBCE58135D} + Exe + Properties + Assignment1 + Assignment1 + v4.5.2 + 512 + 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/Assignment1/Calculator.cs b/Assignment1/Calculator.cs new file mode 100644 index 0000000..823e94c --- /dev/null +++ b/Assignment1/Calculator.cs @@ -0,0 +1,169 @@ +/** +@file calculator.cs +@author Robert Carll Robert-a-c@live.com +@version 1.0 + +Additions and modifications are my sole work for prog 1266 + +@section DESCRIPTION + + + +*/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Assignment1 +{ + public class Calculator + { + public string leftOperand = ""; // + public string rightOperand = ""; // + public string operand = ""; // Variables used in the program + public double lhs = 0; // + public double rhs = 0; // + public double result = 0; // + public bool isNumber = false; + + public void getOperands() // asks user for input + { + do // + { // + Console.WriteLine("Input your left number: "); // + leftOperand = Console.ReadLine(); // Prompts user for left number repeats if invalid + isNumber = Double.TryParse(leftOperand, out lhs); // + // + if (!isNumber) // + Console.WriteLine("Error"); // + } while (!isNumber); + + + do // + { // + Console.WriteLine("Input your operand: "); // asks user for middle operand + operand = Console.ReadLine(); // + + if (operand != "a" && operand != "A" && operand != "+" && operand != "d" && operand != "D" && // + operand != "/" && operand != "M" && operand != "m" && operand != "*" && operand != "S" && // + operand != "s" && operand != "-" && operand != "^" && operand != "E" && operand != "e" && // if invalid print error + operand != "!" && operand != "f" && operand != "F") // + Console.WriteLine("Error"); // + + } while (operand != "a" && operand != "A" && operand != "+" && operand != "d" && operand != "D" && // repeat until valid + operand != "/" && operand != "M" && operand != "m" && operand != "*" && operand != "S" && // + operand != "s" && operand != "-" && operand != "^" && operand != "E" && operand != "e" && // + operand != "!" && operand != "f" && operand != "F"); + + if (operand != "F" && operand != "f" && operand != "!") // If middle operand is not factorial + { // + do // + { // + Console.WriteLine("Input your right number: "); // prompt user for right number + rightOperand = Console.ReadLine(); // + isNumber = Double.TryParse(rightOperand, out rhs); // + // + if (!isNumber) // if it's not a number print error + Console.WriteLine("Error"); // + // + } while (!isNumber); // repeat until entry is a number + } + } + + public void doMath() // calls the appropriate math function based on middle operand + { + switch (operand) + { + case "A": // + case "a": // + case "+": // addition + add(); // + break; // + + case "S": // + case "s": // + case "-": // subtraction + subtract(); // + break; // + + case "D": // + case "d": // + case "/": // divide + divide(); // + break; // + + case "M": // + case "m": // + case "*": // multiplication + multiply(); // + break; // + + case "^": // + case "E": // + case "e": // exponential + exponential(); // + break; // + + case "!": // + case "f": // + case "F": // factorial + factorial(); // + break; // + + default: // default case + break; // + } + if (result > 1000000 || result < -1000000) // if result is greater then 1 million or -1 million print overflow + Console.WriteLine("Overflow"); // + else // + { // otherwise print out the answer + Console.WriteLine("Answer is: " + result); // + } // + + + } + + public void add() // addition method + { // + result = lhs + rhs; // + } // + public void subtract() // subtraction method + { // + result = lhs - rhs; // + } // + public void multiply() // multiplication method + { // + result = lhs * rhs; // + } // + public void divide() // division method + { // + if (rhs == 0) // if right number is 0 print Div0 + { // + Console.WriteLine("Div0"); // + } // + else // otherwise print result + result = lhs / rhs; // + } // + public void exponential() // exponential method + { // + result = Math.Pow(lhs, rhs); // + } // + // + public void factorial() // factorial method + { // + if (lhs < 0) // if left number is a negative number print out error + Console.WriteLine("Error"); // + else // otherwise do factorial math in a for loop + { // + long factorial = (long)lhs; // explicit conversion from double to long + // + for (int i = 1; i < lhs; i++) // + factorial = factorial * i; // + // + result = factorial; // implicit conversion from long to double + } // + } // + } +} diff --git a/Assignment1/Program.cs b/Assignment1/Program.cs new file mode 100644 index 0000000..104c243 --- /dev/null +++ b/Assignment1/Program.cs @@ -0,0 +1,43 @@ +/** +@file program.cs +@author Robert Carll Robert-a-c@live.com +@version 1.0 + +Additions and modifications are my sole work for prog 1266 + +@section DESCRIPTION + + + +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Threading; + +namespace Assignment1 +{ + public class Program + { + static void Main(string[] args) + { + + Calculator calc = new Calculator(); // creates calculator + string quit = ""; // string to test for quit + + do + { + Console.Clear(); //clears screen for easier reading + calc.getOperands(); //gets input from the user + calc.doMath(); //calls the functions that do the calculations based on user input + + Console.WriteLine("Press Q to quit or any key to continue."); // prompts user to continue or quit + quit = Console.ReadLine(); // + + } while (quit != "q" && quit != "Q"); //loop continues until user hits q when prompted + } + } +} diff --git a/Assignment1/Properties/AssemblyInfo.cs b/Assignment1/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f16d8df --- /dev/null +++ b/Assignment1/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("Assignment1")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Assignment1")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[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("27b52ab6-22bf-45bb-9007-bdbbce58135d")] + +// 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")]