using System.Collections.Generic;
public static void Main()
string partition = "Occupied";
List<float> jobs = new List<float>();
List<string> fails = new List<string>();
Console.WriteLine("M3: ML- ACT6 Single-User Contiguous Scheme");
Console.WriteLine("Bravo, Jhade Lambert L.\n");
Console.Write("Input the size of memory(k): ");
input = Console.ReadLine();
if (float.TryParse(input, out memorySize))
Console.Write("Input the size of the Operating System(k): ");
input = Console.ReadLine();
if (float.TryParse(input, out os_Size))
for (int i = 0; i < 6; i++)
Console.WriteLine("M3: ML- ACT6 Single-User Contiguous Scheme");
Console.WriteLine("Bravo, Jhade Lambert L.\n");
Console.WriteLine("Memory Size: " + memorySize + "k");
Console.WriteLine("OS Size: " + os_Size + "k");
tryAgain = "placeholder";
Console.Write("\nInput Job " + (i + 1) + "/" + 6 + " number: ");
input = Console.ReadLine();
if (float.TryParse(input, out jobInput))
if (jobInput <= memorySize)
Console.WriteLine("\nWarning. Input for J" + (i + 1) + " is greater than the memory size.");
Console.WriteLine("Would you like to re-input a new value to the job?:");
Console.WriteLine("Invalid Input. Input only accepts positive numbers.");
Console.Write("\nPress [Y/y] and enter to re-input or press enter only to continue anyway: ");
tryAgain = Console.ReadLine();
if (float.TryParse(input, out jobInput))
while ((tryAgain == "Y") || (tryAgain == "y"));
for (int i = 0; i < 6; i++)
Console.WriteLine("M3: ML- ACT6 Single-User Contiguous Scheme");
Console.WriteLine("Bravo, Jhade Lambert L.\n");
Console.WriteLine("OS(" + os_Size + "k), J" + (i + 1) + "(" + jobs[i] + "k), Unused(" + memorySize + "k)\n");
Console.WriteLine("Job Lists:");
foreach (float j in jobs)
Console.Write("Job " + counter2 + "(" + j + "k)");
if (jobs[i] <= memorySize)
Console.WriteLine("Memory for J" + (i + 1) + " was successfully allocated.");
Console.WriteLine("Press [0] and enter to allocate or press [1] to deallocate");
Console.Write("\n[0]Allocate/[1]Deallocate: ");
input = Console.ReadLine();
if (Int32.TryParse(input, out number))
if (partition == "Occupied")
Console.WriteLine("Allocation cannot be executed. Partition is currently occupied");
Console.WriteLine("Input again please.");
else if (number == deallocate)
Console.WriteLine("Job " + (i + 1) + " has been deallocated");
Console.WriteLine("Partition is now available for allocation.");
Console.WriteLine("Invalid input. 0 and 1 only. ");
Console.WriteLine("Invalid input. 0 and 1 only. ");
Console.WriteLine("\nInput again? [Y/y]: ");
input = Console.ReadLine();
Console.WriteLine("Memory for J" + (i + 1) + " cannot be allocated due to insufficient storage of the memory.");
fails.Add("Job" + (i + 1) + "(" + jobs[i] + "k)");
Console.Write("\n\nPress enter to continue... ");
pause = Console.ReadLine();
Console.WriteLine("M3: ML- ACT6 Single-User Contiguous Scheme");
Console.WriteLine("Bravo, Jhade Lambert L.\n");
Console.WriteLine("\nConlusion");
Console.WriteLine("All jobs are allocated succesfully.");
Console.WriteLine("\nNot all jobs were succesfully allocated.");
Console.WriteLine("The following list of job/s that failed the allocation are displayed below:");
foreach (string i in fails)
Console.WriteLine("Invalid Input. Input only accepts positive numbers and must be below to the memory size.");
Console.WriteLine("Invalid Input. Input only accepts positive numbers.");
Console.Write("\nProgram will end. Try Again? [Y/y]: ");
tryAgain = Console.ReadLine();
while ((tryAgain == "Y") || (tryAgain == "y"));
Console.WriteLine("End of the program. Press enter key to exit..");