@@ -6,19 +6,19 @@ class MemoryBlock {
6
6
boolean [] free = new boolean [] { false , true , false , true , false , true , false , true };
7
7
int [] processNumber = new int [] { 1 , 2 , 3 , 4 };
8
8
int divs = memory .length ;
9
- int processSize ;
9
+ int processSize ;
10
10
Scanner s = new Scanner (System .in );
11
11
12
12
void processInput () {
13
- System .out .println ("Current Scenario of the Memory Allocation" );
13
+ System .out .println ("\n \t Current Scenario of the Memory Allocation \n " );
14
14
printTable (-1 );
15
15
System .out .print ("Enter the size of the process that needs to be added (in KB): " );
16
16
processSize = s .nextInt ();
17
- System .out .println ("After First Fit \n " );
17
+ System .out .println ("\n \t \t After First Fit \n " );
18
18
firstFit ();
19
- System .out .println ("After Best Fit \n " );
19
+ System .out .println ("\n \t \t After Best Fit \n " );
20
20
bestFit ();
21
- System .out .println ("After Worst Fit \n " );
21
+ System .out .println ("\n \t \t After Worst Fit \n " );
22
22
worstFit ();
23
23
}
24
24
@@ -60,21 +60,24 @@ void worstFit() {
60
60
}
61
61
62
62
void printTable (int pos ) {
63
- System .out .print ("No. \t Memory \t Status \t Process \n " );
63
+ System .out .print ("+----------------------------------------------------------+\n " );
64
+ System .out .print ("|\t No.\t Memory \t \t Status \t Process |\n " );
65
+ System .out .print ("+----------------------------------------------------------+\n " );
64
66
int j = 1 , ok = 0 ;
65
67
for (int i = 0 ; i < divs ; i ++) {
66
68
if (i == pos ) {
67
- System .out .print (i + 1 + " \t " + processSize + " \t " + "NF \t " + "Process " + (processNumber .length + 1 ) + "\n " );
69
+ System .out .print ("| \t " + ( i + 1 ) + " \t " + processSize + " \t \t " + " NF \t \t " + "Process " + (processNumber .length + 1 ) + " | " );
68
70
if (memory [i ] - processSize != 0 ) {
69
- System .out .print (i + 2 + " \t " + (memory [i ] - processSize ) + " \t " + "F \t " );
71
+ System .out .print (" \n | \t " + ( i + 2 ) + " \t " + (memory [i ] - processSize ) + " \t \t " + " F \t \t \t | " );
70
72
ok = 1 ;
71
73
}
72
74
}
73
75
else {
74
- System .out .print ((i + 1 + ok ) + " \t " + memory [i ] + " \t " + ((free [i ]) ? "F" : "NF \t " + "Process " + j ++));
76
+ System .out .print ("| \t " + (i + 1 + ok ) + " \t " + memory [i ] + " \t \t " + ((free [i ]) ? "F \t \t \t | " : "NF \t \t " + "Process " + j ++ + " |" ));
75
77
}
76
78
System .out .println (' ' );
77
79
}
80
+ System .out .print ("+----------------------------------------------------------+\n " );
78
81
}
79
82
}
80
83
0 commit comments