Monday, November 3, 2014

Code

this is what i have done how do i make sure that the total is 10 and when i enter a new contact it takes the space and lets me how much space i have left


You can put the total on top and each time a new car takes a space you can minus the total:



static void Main(string[] args)
{
int Totalspace = 10;
string name;
Console.WriteLine("Valvet Parking");

for (int i = 0; i < 10; i++)
{
if (Totalspace > 0)
{
Console.WriteLine("Please enter Name");
name = Console.ReadLine();
Console.WriteLine("{0} has been stored", name);
Console.WriteLine("Enter the License plate Number");
LicenseplateNumber = Console.ReadLine();
Totalspace -= 1;
Console.WriteLine("");
Console.WriteLine("{0} space is left", Totalspace);
Console.WriteLine("");
Console.WriteLine("No more car enter ? Y/N");
string stop = Console.ReadLine();
if (stop.ToUpper() == "N")
{
Console.WriteLine("There is {0} space left", Totalspace);
break;
}
}
}
}
public static string LicenseplateNumber { get; set; }




No comments:

Post a Comment