C#
C# 사칙연산
Dev_Jen
2023. 3. 12. 00:03
반응형
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _1주차_복습
{
class Program
{
#region 사칙연산
public void math()
{
Console.Write("a값을 입력하세요: ");
int a = Int32.Parse(Console.ReadLine());
Console.Write("b값을 입력하세요: ");
int b = Int32.Parse(Console.ReadLine());
Console.WriteLine("0번 - 더하기");
Console.WriteLine("1번 - 빼기");
Console.WriteLine("2번 - 곱하기");
Console.WriteLine("3번 - 나누기");
Console.Write("선택 : ");
int c = Int32.Parse(Console.ReadLine());
switch (c)
{
case 0:
Console.WriteLine("값 : {0}", a + b);
break;
case 1:
Console.WriteLine("값 : {0}", a - b);
break;
case 2:
Console.WriteLine("값 : {0}", a * b);
break;
case 3:
Console.WriteLine("값 : {0}", a / b);
break;
}
}
#endregion
static void Main(String[] args)
{
Program Pro = new Program();
Pro.math();
}
}
}
반응형