Well I’ve manged to work it out its a pretty simple maths equation Length x Width x Height. Lets start with the design of how this should be presented, well I’m work on Windows Form Applications so it should be in a Form, should have 3 text boxes that the user enters 3 values in one for length one for width one for height. Then once that’s sorted then need a button that makes the calculation happen, whilst we are at it may as well make a spot for where the answer is spat out to.
With how simple the math seems it should be pretty straight forward to code, I manage to get rather stuck on when trying converting Text Boxes to Integers.
How I managed to do this:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15public void BtnCalculate_Click(object sender, EventArgs e)
{
//LenghtxWidthxHeight
int Length;
int Width;
int Height;
int Answer;
Length = int.Parse(TxtBLength.Text); //converts TextBox .Text's to Interger from String
Width = int.Parse(TxtBWidth.Text);
Height = int.Parse(TxtBHeight.Text);
Answer = Length * Width * Height;
TxtBAnswer.Text = (Answer.ToString());
}
