Skip to content

Latest commit

 

History

History
32 lines (20 loc) · 895 Bytes

Task-4.md

File metadata and controls

32 lines (20 loc) · 895 Bytes

Practical One, Task Four

Getting to grips with variables

Now its time to test your knowledge.

Step One

  • Create a new project as shown in Task One
  • Create three int variables, and call them width, height and area
  • Use Console.ReadLine(); to initialise the height and width variables

You may notice this gives an error,

image

  • 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);