Question: my method dosent print the last procces please help me fix it public static void reportMemory() { int start = -1; int end = -1;

my method dosent print the last procces please help me fix it

public static void reportMemory() { int start = -1; int end = -1; int currentProcess = -1;

for (int i = 0; i < MAX; i++) { int address = addresses[i]; if (address != 0) { if (currentProcess == -1) { // First used address found start = i; currentProcess = address; } else if (address != currentProcess) { // New process found end = i - 1; System.out.printf("Addresses [%d, %d] Process P%d ", start, end, currentProcess - 1); start = i; currentProcess = address; } } else { if (currentProcess != -1) { // End of used address range found end = i - 1; System.out.printf("Addresses [%d, %d] Process P%d ", start, end, currentProcess - 1); currentProcess = -1; } } }

// Check if there's a range of unused addresses at the end if (currentProcess == -1) { System.out.printf("Addresses [%d, %d] Unused ", end + 1, MAX - 1); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!