파일 목록
-
📁 10
-
📁 3
-
📁 4
-
📁 4-minicalc
-
📁 7
-
📁 parking manager
- 2.cs
- desktop.ini
- Title.png
- 객체지향 3대 특징(+1).txt
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace MiniCalc
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void add_Click(object sender, EventArgs e)
{
float num1, num2, re;
if (float.TryParse(tbxnum1.Text, out num1))
{
if (float.TryParse(tbxnum2.Text, out num2))
{
re = num1 + num2;
if (re % 1 == 0) {
re = (int)Math.Round(re);
}
result.Text = re.ToString();
}
else result.Text = "숫자를 쓰세요";
}
else result.Text = "숫자를 쓰세요";
}
private void sub_Click(object sender, EventArgs e)
{
float num1, num2, re;
if (float.TryParse(tbxnum1.Text, out num1))
{
if (float.TryParse(tbxnum2.Text, out num2))
{
re = num1 - num2;
if (re % 1 == 0)
{
re = (int)Math.Round(re);
}
result.Text = re.ToString();
}
else result.Text = "숫자를 쓰세요";
}
else result.Text = "숫자를 쓰세요";
}
private void mul_Click(object sender, EventArgs e)
{
float num1, num2, re;
if (float.TryParse(tbxnum1.Text, out num1))
{
if (float.TryParse(tbxnum2.Text, out num2))
{
re = num1 * num2;
if (re % 1 == 0)
{
re = (int)Math.Round(re);
}
result.Text = re.ToString();
}
else result.Text = "숫자를 쓰세요";
}
else result.Text = "숫자를 쓰세요";
}
private void div_Click(object sender, EventArgs e)
{
float num1, num2, re;
if (float.TryParse(tbxnum1.Text, out num1))
{
if (float.TryParse(tbxnum2.Text, out num2))
{
re = num1 / num2;
if (re % 1 == 0)
{
re = (int)Math.Round(re);
}
result.Text = re.ToString();
}
else result.Text = "숫자를 쓰세요";
}
else result.Text = "숫자를 쓰세요";
}
}
}