Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- using System.Text;
- using System.Runtime;
- using System.Media;
- using System.IO;
- using System.Net;
- namespace Simple_Calculator
- {
- class Calc
- {
- public static String num1String;
- public static String num2String;
- public static double num1;
- public static double num2;
- public static String oper;
- public static String response;
- public static void Main (string[] args)
- {
- if (args [0] == "-operators") {
- Console.WriteLine ("OPERATORS");
- Console.WriteLine ("\"+\" - add");
- Console.WriteLine ("\"-\" - subtract");
- Console.WriteLine ("\"*\" - multiply");
- Console.WriteLine ("\"/\" - divide");
- Console.WriteLine ("\"sin\" - calculate sine (if you use this operator, the second number does not count.)");
- Console.WriteLine ("\"cos\" - calculate cosine (if you use this operator, the second number does not count.)");
- Console.WriteLine ("\"%\" - calculate modulo (if you use this operator, the second number does not count.)");
- Console.WriteLine ("\"log\" - calculate logarithmic math");
- Console.WriteLine ("\"exp\" - calculate exponents");
- Console.WriteLine ("\"tan\" - calculate tangents (if you use this operator, the second number does not count.)");
- }
- Console.WriteLine ("Simple Text-Based Calculator by Aaron Murphy");
- Console.Write ("First Number>> ");
- num1String = Console.ReadLine ();
- num1 = Convert.ToInt32 (num1String);
- Console.WriteLine ("");
- Console.Write ("Second Number>> ");
- num2String = Console.ReadLine ();
- num2 = Convert.ToInt32 (num2String);
- Console.WriteLine ("");
- Console.Write ("Operator(+, -, *, /, sin, cos, %, log, exp, and tan)>> ");
- oper = Console.ReadLine ();
- Console.WriteLine ("");
- if (oper == "+") {
- Console.WriteLine (num1 + " + " + num2 + " = " + (num1 + num2));
- } else if (oper == "-") {
- Console.WriteLine (num1 + " - " + num2 + " = " + (num1 - num2));
- } else if (oper == "*") {
- Console.WriteLine (num1 + " * " + num2 + " = " + (num1 * num2));
- } else if (oper == "/") {
- Console.WriteLine (num1 + " / " + num2 + " = " + (num1 / num2));
- } else if (oper == "sin") {
- Console.WriteLine ("Sin(" + num1 + ") = " + Math.Sin (num1));
- } else if (oper == "cos") {
- Console.WriteLine ("");
- } else if (oper == "%") {
- } else if (oper == "log") {
- } else if (oper == "exp") {
- } else if (oper == "tan") {
- }
- Console.WriteLine ("");
- Console.Write ("Do you want to perform a new calculation(Y/N)?>> ");
- response = Console.ReadLine ();
- if (response == "Y" || response == "y") { //It works if the user types "Y" or "y".
- Console.WriteLine ("");
- Main (null);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment