Diberdayakan oleh Blogger.
RSS

3.Kalkulator

using System;

namespace kalkulator_0320100019
{
///


/// Summary description for Class1.
///

class Class1
{
///
/// The main entry point for the application.
///

[STAThread]
static void Main(string[] args)
{
int a,c,d;
decimal e;
char b;
Console.Write("Angka 1 : ");
a = Convert.ToInt32(Console.ReadLine());
Console.Write("Operator (+, -, *, /) : ");
b = Convert.ToChar(Console.ReadLine());
Console.Write("Angka 2 : ");
c = Convert.ToInt32(Console.ReadLine());
switch(b)
{
case '+' : d = a + c;
Console.Write("Jumlah adalah {0}",d);
break;
case '-' : d = a - c;
Console.Write("Jumlah adalah {0}",d);
break;
case '*' : d = a * c;
Console.Write("Jumlah adalah {0}",d);
break;
case '/' : e = Convert.ToDecimal(a) / Convert.ToDecimal(c);
Console.Write("Jumlah adalah {0}",e);
break;
}
Console.ReadLine();
}
}
}

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 komentar:

Posting Komentar