I have this program that inputs 3 integers and then determines which one is the largest. My program works fine, but I really want to write a method that contains the if statements and figures out which
number is the largest.
Problem is I don't know where to put the method header and the resulting code. Right now I've got it I think in the wrong spot cause I'm getting red squiggly lines.
number is the largest.
Problem is I don't know where to put the method header and the resulting code. Right now I've got it I think in the wrong spot cause I'm getting red squiggly lines.
C#:
namespace Find_Maximum_Value
{
public partial class FormFindMaximumValue : Form
{
public FormFindMaximumValue()
{
InitializeComponent();
}
private void buttonCalculate_Click(object sender, EventArgs e)
{
int a, b, c, maximumValue;
a = Convert.ToInt32(textBoxFirstInteger.Text);
b = Convert.ToInt32(textBoxSecondInteger.Text);
c = Convert.ToInt32(textBoxThirdInteger.Text);
maximumValue = a;
if (b > maximumValue)
maximumValue = b;
if (c > maximumValue)
maximumValue = c;
labelAnswer.Text = "Maximum value is " + maximumValue;
}
private void buttonClear_Click(object sender, EventArgs e)
{
textBoxFirstInteger.Text = " ";
textBoxSecondInteger.Text = " ";
textBoxThirdInteger.Text = " ";
labelAnswer.Text = " ";
}
public static int Maximum(a, b, c)
{
int maximumValue = a;
if (b > maximumValue)
maximumValue = b;
if (c > maximumValue)
maximumValue = c;
}