using System.Collections.Generic;
public static void Main()
string[] outputArray = { "M3: ML- ACT7 Fixed Partition - First Fit", "Panlaqui, Ezzexckquiel Lledor M.", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " };
Console.WriteLine("M3: ML- ACT7 Fixed Partition - First Fit");
Console.WriteLine("Panlaqui, Ezzexckquiel Lledor M.");
Console.WriteLine("Enter the size of OS:");
oss = Console.ReadLine();
Console.WriteLine("Enter the size of Memory:");
memorys = Console.ReadLine();
Console.WriteLine("Enter the amount of jobs:");
jobinput = Console.ReadLine();
if (Double.TryParse(oss, out os) == true && Double.TryParse(memorys, out memory) == true && Int32.TryParse(jobinput, out jo) == true)
if (os <= -1 || memory <= -1 || jo <= -1)
Console.WriteLine("Error of input");
Console.Write("\n\nPress enter to continue... ");
pause = Console.ReadLine();
foreach (string j in outputArray)
Console.WriteLine(j.ToString());
if (j == "Panlaqui, Ezzexckquiel Lledor M.")
else if (os >= 0 && memory >= 0 && jo >= 0)
List<double> aloc = new List<double>();
List<int> tatss = new List<int>();
double[] memos = new double[2];
allocation = memory - os;
for (int r = 0; r < jo; r++)
Console.WriteLine("Memory size " + aac + "M ");
Console.WriteLine("OS size " + os + "M ");
Console.WriteLine("Enter job number " + (r + 1) + ": ");
inputss = Console.ReadLine();
if (Double.TryParse(inputss, out job) == true)
if ((job >= 0) && (job <= aac))
Console.WriteLine("Wrong input for job, Please try again");
Console.Write("\n\nPress enter to continue... ");
pause = Console.ReadLine();
outputArray[r + 3] = " ";
foreach (string j in outputArray)
Console.WriteLine(j.ToString());
if (j == "Panlaqui, Ezzexckquiel Lledor M.")
for (int i = 0; i < jo; i++)
Console.WriteLine("Memory size " + allocation + "M ");
Console.WriteLine("OS size " + os + "M ");
Console.WriteLine("Enter TAT for job " + (i + 1) + ":");
input = Console.ReadLine();
if (Int32.TryParse(input, out time) == true)
Console.WriteLine("Wrong input for Turn Around Time for the jobs, Please try again.");
Console.WriteLine("Press enter to continue... ");
pause = Console.ReadLine();
outputArray[i + 3] = " ";
foreach (string j in outputArray)
Console.WriteLine(j.ToString());
if (j == "Panlaqui, Ezzexckquiel Lledor M.")
Console.WriteLine("Memory size: " + memos[0]);
Console.WriteLine("OS size: " + memos[1]);
Console.WriteLine("Job List:");
Console.WriteLine("Job" + (e + 1) + " " + aloc[e] + "K ");
Console.Write("\n\nPress enter to continue... ");
pause = Console.ReadLine();
Console.WriteLine("Turn Around Time (TAT):");
Console.WriteLine("TAT " + (e + 1) + " " + tatss[e] + " ");
Console.Write("\n\nPress enter to continue... ");
pause = Console.ReadLine();
int allocjobs = aloc.Count;
List<int> remove = new List<int>();
List<string> fails = new List<string>();
Console.WriteLine("M3: ML- ACT7 Fixed Partition - First Fit");
Console.WriteLine("Panlaqui, Ezzexckquiel Lledor M.");
Console.WriteLine("Memory size: " + memos[0]);
Console.WriteLine("OS size: " + memos[1]);
Console.WriteLine("Number of Jobs: " + jo);
Console.WriteLine("\nJob Lists:");
Console.WriteLine("\nJob\t\tSize\t\tTAT");
foreach (float j in aloc)
Console.Write("Job " + (ctr + 1));
Console.Write("\t\t" + j + "M");
Console.Write("\t\t" + tatss[ctr]);
Console.WriteLine("Set " + set);
Console.WriteLine("Memory\t\tParition Size\tAllocation");
Console.WriteLine("OS Partition" + "\t" + memos[1] + "M\t\tOS");
for (int i = 0; i < aloc.Count; i++)
if ((allocation >= aloc[i]))
Console.WriteLine("Partition " + ctr + "\t" + aloc[i] + "M\t\tJob " + (i + 1) + "\t\t\tTAT Left " + remove[i]);
if (aloc[i] > memory - os)
fails.Add("Job" + (i + 1) + "(" + aloc[i] + "M) TAT: " + tatss[i]);
Console.WriteLine("Partition " + ctr + "\t" + allocation + "M\t\tFree Memory Space");
allocation = memory - os;
Console.Write("\n\nPress enter to continue... ");
pause = Console.ReadLine();
Console.WriteLine("M3: ML- ACT7 Fixed Partition - First Fit");
Console.WriteLine("Panlaqui, Ezzexckquiel Lledor M.");
Console.WriteLine("Conclusion");
if (allocjobs == aloc.Count)
Console.WriteLine("All " + aloc.Count + " jobs are allocated succesfully.");
Console.WriteLine("There are " + set + " sets of allocation.");
List<string> outputFail = fails.Distinct().ToList();
Console.WriteLine("Memory Size: " + memory + "k");
Console.WriteLine("\nNot all jobs were succesfully allocated.");
Console.WriteLine("The following list of job/s that failed to allocate are displayed below:");
foreach (string i in outputFail)
Console.WriteLine("Invalid input of memory and os size");
foreach (string j in outputArray)
Console.WriteLine(j.ToString());
if (j == "Panlaqui, Ezzexckquiel Lledor M.")
Console.WriteLine("Do you like to continue the program? [Yes/No]");
answer = Console.ReadLine();
} while (answer == "Y" || answer == "y" || answer =="Yes" || answer == "yes");
Console.WriteLine("Thank you for using the program.");