Midterm 2
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;
namespace midterm2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button_calculate_Click(object sender, EventArgs e)
{
string dinedAmount = textBox_dined.Text;
//int dinedInt = int.Parse(dinedAmount);
int dinedInt;
string points = "";
if (int.TryParse(dinedAmount, out dinedInt))
{
switch (dinedInt)
{
case 0:
points = "0 points";
break;
case 1:
points = "5 points";
break;
case 2:
points = "15 points";
break;
case 3:
points = "30 points";
break;
default:
points = "60 points";
break;
}
label_dinedAmount.Text = "You have dined " + dinedAmount + " times this month
and have been awarded this many points:";
label_pointsTotal.Text = points;
}
else
{
MessageBox.Show("Please only enter a number");
textBox_dined.Text = "";
textBox_dined.Focus();
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button_close_Click(object sender, EventArgs e)
{
this.Close();
}
private void button_clear_Click(object sender, EventArgs e)
{
label_dinedAmount.Text = "";
label_pointsTotal.Text = "";
textBox_dined.Text = "";
textBox_dined.Focus();
}
}
}