-
-
Save joshmcarthur/1138324 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Text; | |
using System.Windows.Forms; | |
namespace Alexander_Sean_McArthur_300229975 | |
{ | |
public partial class PersonalFitnessForm : Form | |
{ | |
public PersonalFitnessForm() | |
{ | |
InitializeComponent(); | |
} | |
private void Simulation_Click(object sender, EventArgs e) | |
{ | |
} | |
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) | |
{ | |
} | |
private void clearButton_Click(object sender, EventArgs e) | |
{ | |
genderComboBox.SelectedIndex = -1; | |
nameTextBox.Clear(); | |
weightTextBox.Clear(); | |
heightTextBox.Clear(); | |
calculateBmiTextBox.Clear(); | |
aerobicsTextBox.Clear(); | |
runningTextBox.Clear(); | |
swimmingTextBox.Clear(); | |
hikingTextBox.Clear(); | |
walkingTextBox.Clear(); | |
sittingTextBox.Clear(); | |
totalCaloriesTextBox.Clear(); | |
} | |
private void exitButton_Click(object sender, EventArgs e) | |
{ | |
this.Close(); | |
} | |
private void PersonalFitnessTrackerForm_Load(object sender, EventArgs e) | |
{ | |
this.dateTextBox.Text = DateTime.Now.ToString(); | |
} | |
private void calculateBmiButton_Click(object sender, EventArgs e) | |
{ | |
if (weightTextBox.Text == "") | |
{ | |
MessageBox.Show("Please Enter A valid Weight", "Entry Error"); | |
weightTextBox.Focus(); | |
return; | |
} | |
if (heightTextBox.Text == "") | |
{ | |
MessageBox.Show("Please Enter A Validate Height", "Entry Error"); | |
heightTextBox.Focus(); | |
return; | |
} | |
decimal weight = decimal.Parse(weightTextBox.Text); | |
decimal height = decimal.Parse(heightTextBox.Text); | |
//Calculate BMI, convert decimal to double as math.pow will not accept double arguements | |
decimal bmi = Convert.ToDecimal(Convert.ToDouble(weight) / Math.Pow(Convert.ToDouble(height), 2)); | |
calculateBmiTextBox.Text = Math.Round(bmi, 2).ToString(); | |
} | |
private void dateTextBox_TextChanged(object sender, EventArgs e) | |
{ | |
} | |
private void calculateCaloriesButton_Click(object sender, EventArgs e) | |
{ | |
decimal aerobicDecimal = decimal.Parse(aerobicsTextBox.Text); | |
decimal runningDecimal = decimal.Parse(runningTextBox.Text); | |
decimal swimmingDecimal = decimal.Parse(swimmingTextBox.Text); | |
decimal hikingDecimal = decimal.Parse(hikingTextBox.Text); | |
decimal walkingDecimal = decimal.Parse(walkingTextBox.Text); | |
decimal sittingDecimal = decimal.Parse(sittingTextBox.Text); | |
decimal total_calories = 0; | |
//whatever total calories variable is plus result of what is on the right | |
total_calories += aerobicDecimal * 12.5m; | |
total_calories += runningDecimal * 14.2m; | |
total_calories += swimmingDecimal * 11.3m; | |
total_calories += hikingDecimal * 18.9m; | |
total_calories += walkingDecimal * 5.7m; | |
total_calories += sittingDecimal * 1.3m; | |
totalCaloriesTextBox.Text = Math.Round(total_calories, 1).ToString(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment