More MP2 Progress
This commit is contained in:
62
MP2/Problem2BookClubPoints_CalebFontenot/Form1.cs
Executable file
62
MP2/Problem2BookClubPoints_CalebFontenot/Form1.cs
Executable file
@@ -0,0 +1,62 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user