61 lines
1.5 KiB
C#
61 lines
1.5 KiB
C#
|
namespace Problem2BookClubPoints_CalebFontenot
|
||
|
{
|
||
|
public partial class Form1 : Form
|
||
|
{
|
||
|
public Form1()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
}
|
||
|
|
||
|
private void okButton_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
|
||
|
|
||
|
try
|
||
|
{
|
||
|
// Define variables
|
||
|
int booksPurchased,
|
||
|
pointsEarned = 0;
|
||
|
|
||
|
|
||
|
// Get data
|
||
|
booksPurchased = int.Parse(booksPurchasedTextBox.Text);
|
||
|
|
||
|
// Determine points earned with if logic:
|
||
|
if (booksPurchased >= 4)
|
||
|
{
|
||
|
pointsEarned = 60;
|
||
|
}
|
||
|
if (booksPurchased == 3)
|
||
|
{
|
||
|
pointsEarned = 30;
|
||
|
}
|
||
|
if (booksPurchased == 2)
|
||
|
{
|
||
|
pointsEarned = 15;
|
||
|
}
|
||
|
if (booksPurchased == 1)
|
||
|
{
|
||
|
pointsEarned = 5;
|
||
|
}
|
||
|
if (booksPurchased == 0)
|
||
|
{
|
||
|
pointsEarned = 0;
|
||
|
}
|
||
|
|
||
|
// Write pointsEarned to textbox.
|
||
|
pointsTextBox.Text = pointsEarned.ToString();
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
MessageBox.Show("Invalid Input");
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
private void exitButton_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
this.Close();
|
||
|
}
|
||
|
}
|
||
|
}
|