Now its time to test your knowledge.
Step One
- Create a new project as shown in Task One
- Create three
int
variables, and call themwidth
,height
andarea
- Use
Console.ReadLine();
to initialise the height and width variables
You may notice this gives an error,
- You need to convert the
Console.ReadLine();
to an integer. - To do this, use the
Convert.ToInt32();
method:
int width = Convert.ToInt32( Console.ReadLine() );
- Do the same for height
- Find the area of the shape by multiplying the two variables
- Finally, print out the area using:
Console.WriteLine(area);