So I'm trying to make a program that allows users to insert values for length and width and then another method is called to calculate the area and perimeter. Howevever, I can't seem to get past the user input part.
The whole program is closed after I hit enter for the length. I read that the Read command is terminated after you hit the enter key, so all I'm wondering is how am I supposed to go about enabling a user to enter multiple values. I tried putting WriteLine commands in between the Read commands, but that doesn't stop the program from closing.
Here is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IntroToCSharp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Length?");
int length = Console.Read();
Console.WriteLine("Width?");
int width = Console.Read();
Console.WriteLine("Good!");
Perimeter(length, width);
}
public static double Area(int length, int width)
{
return length * width;
}
}
}