Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Intuit // C# // listing_4.7 (case // calculator)
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.IO; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here string buf; double a,b,res; Console.Write("Enter the first operand: "); a = double.Parse(Console.ReadLine()); Console.WriteLine(" a = {0,5}", a); Console.Write("Enter the operation sign:"); char op = (char)Console.Read(); Console.ReadLine(); Console.WriteLine(" op = {0,5}", op); Console.Write("Enter the second operand: "); b = double.Parse(Console.ReadLine()); Console.WriteLine(" b = {0,5}", b); bool ok = true; switch (op){ case '+' : res = a+b; break; case '-' : res = a-b; break; case '/' : res = a/b; break; case '*' : res = a*b; break; case '^' : res = Math.Pow(a,b); break; default : res = double.NaN; ok = false; break; } if (ok) Console.WriteLine("Result is = " + res); else Console.WriteLine("ERROR"); } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
ReplaceNotExpectedCharacters
Valid Substring
Range List for C#
🎄CoinBase Support Number🎄 (1.201.277 .8882)🎄 Online Helpline Pro Toll Free 🎄Customers
SELECT YEAR('2019-08-15 01:02:03')+10
Map usernames from domain\username format to username@domain.com format
Reflection constructors
My
Main2
TestKlasse
Please log in to post a comment.