Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Calculator
- {
- using System;
- using System.IO;
- static class Calculator
- {
- static void Main()
- {
- Console.WriteLine("Content-Type: text/html\r\n");
- string htmlContent = File.ReadAllText("../www/calculator.html");
- Console.WriteLine(htmlContent);
- string post = Console.ReadLine();
- if (post != null)
- {
- string[] postSplited = post.Split(new[] { '&', '=' }, StringSplitOptions.RemoveEmptyEntries);
- double firstNum = double.Parse(postSplited[1]);
- string operation = postSplited[3];
- double secondNum = double.Parse(postSplited[5]);
- switch (operation)
- {
- case "%2B": // + sign
- Console.WriteLine("Result: " + (firstNum + secondNum));
- break;
- case "-": // - sign
- Console.WriteLine("Result: " + (firstNum - secondNum));
- break;
- case "*": // * sign
- Console.WriteLine("Result: " + (firstNum * secondNum));
- break;
- case "%2F": // / sign
- Console.WriteLine("Result: " + (firstNum / secondNum));
- break;
- default:
- Console.WriteLine("Invalid sign!");
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment