From 3fa2ca605bff7f741096c3c69f5650c9e6b1b4b2 Mon Sep 17 00:00:00 2001 From: ​ Date: Thu, 1 Jan 1970 00:00:00 +0000 Subject: coin counter --- coin_counter/Coin Counter/mainForm.cs | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 coin_counter/Coin Counter/mainForm.cs (limited to 'coin_counter/Coin Counter/mainForm.cs') diff --git a/coin_counter/Coin Counter/mainForm.cs b/coin_counter/Coin Counter/mainForm.cs new file mode 100644 index 0000000..b741507 --- /dev/null +++ b/coin_counter/Coin Counter/mainForm.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics.Eventing.Reader; +using System.Drawing; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Coin_Counter +{ + public partial class coinCounter : Form + { + public coinCounter() + { + InitializeComponent(); + } + + private void calcBtn_Click(object sender, EventArgs e) + { + try { + int cents = int.Parse(penniesTxtBox.Text) + + int.Parse(nickelsTxtBox.Text) * 5 + + int.Parse(dimesTxtBox.Text) * 10 + + int.Parse(quartersTxtBox.Text) * 25; + + if (cents < 100) + MessageBox.Show("That's less than a dollar. Try again."); + else if (cents > 100) + MessageBox.Show("That's more than a dollar. Try again."); + else + MessageBox.Show("Congratulations! That's exactly one dollar."); + } + catch { + MessageBox.Show("Enter a whole number in each box."); + } + } + + + private void clearBtn_Click(object sender, EventArgs e) + { + penniesTxtBox.Text = "0"; + nickelsTxtBox.Text = "0"; + dimesTxtBox.Text = "0"; + quartersTxtBox.Text = "0"; + } + + private void exitBtn_Click(object sender, EventArgs e) + { + this.Close(); + } + } +} -- cgit 1.4.1