using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
namespace DentakuConsole
{
class Program
{
public static readonly String OP_ADD = "+";
public static readonly String OP_SUB = "-";
public static readonly String OP_MUL = "*";
public static readonly String OP_DIV = "/";
public static readonly String OP_MOD = "%";
static void Main(string[] args)
{
try
{
var items = parse(Console.In);
var n1 = Double.Parse(items[0]);
items.RemoveAt(0);
for (var et = items.GetEnumerator(); et.MoveNext();)
{
if (et.Current.Equals(OP_ADD))
{
if (et.MoveNext())
{
n1 = Dentaku.Add(n1, Double.Parse(et.Current));
}
}
else if (et.Current.Equals(OP_SUB))
{
if (et.MoveNext())
{
n1 = Dentaku.Sub(n1, Double.Parse(et.Current));
}
}
else if (et.Current.Equals(OP_MUL))
{
if (et.MoveNext())
{
n1 = Dentaku.Mul(n1, Double.Parse(et.Current));
}
}
else if (et.Current.Equals(OP_DIV))
{
if (et.MoveNext())
{
n1 = Dentaku.Div(n1, Double.Parse(et.Current));
}
}
else if (et.Current.Equals(OP_MOD))
{
if (et.MoveNext())
{
n1 = Dentaku.Mod(n1, Double.Parse(et.Current));
}
}
else
{
throw new Exception("OP_ERROR");
}
}
Console.WriteLine("result=" + n1);
}
catch (Exception e)
{
Debug.WriteLine(e);
}
}
private static List<String> parse(TextReader reader)
{
var items = new List<String>();
var sb = new StringBuilder();
var i = -1;
while ((i = reader.Read()) != -1)
{
switch (i)
{
case '\r':
case '\n':
if (sb.Length != 0)
{
items.Add(sb.ToString());
}
return items;
case ' ':
case ' ':
case ',':
case ',':
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
sb.Append(i - '0');
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
sb.Append(i - '0');
break;
case '.':
case '.':
sb.Append('.');
break;
case '+':
case '+':
if (sb.Length == 0)
{
sb.Append('0');
}
items.Add(sb.ToString());
sb.Clear();
items.Add(OP_ADD);
break;
case '-':
case '-':
if (sb.Length == 0)
{
sb.Append('0');
}
items.Add(sb.ToString());
sb.Clear();
items.Add(OP_SUB);
break;
case '*':
case '*':
case '×':
items.Add(sb.ToString());
sb.Clear();
items.Add(OP_MUL);
break;
case '/':
case '/':
case '÷':
items.Add(sb.ToString());
sb.Clear();
items.Add(OP_DIV);
break;
case '%':
case '%':
items.Add(sb.ToString());
sb.Clear();
items.Add(OP_MOD);
break;
}
}
if (sb.Length != 0)
{
items.Add(sb.ToString());
}
return items;
}
}
public class Dentaku
{
public static double Add(double n1, double n2)
{
return n1 + n2;
}
public static double Sub(double n1, double n2)
{
return n1 - n2;
}
public static double Mul(double n1, double n2)
{
return n1 * n2;
}
public static double Div(double n1, double n2)
{
if (n2 == 0)
{
throw new Exception("Div NaN");
}
return n1 / n2;
}
public static double Mod(double n1, double n2)
{
if (n2 == 0)
{
throw new Exception("Mod NaN");
}
return n1 % n2;
}
}
}