title: Translate logical address to page number and index
body: <p>I am supposed to convert the logicalAddress to pageNumber and index, but i don't know how to do this.
  The logicalAddress is a five digit int (the logical address is given as decimal).
  Any hints?</p>
  
  <pre><code>public byte read(int logicalAddress){
      //called by a process to read memory from its logical address
      //this.pageNumber = pageNumber;
      byte data=0;
  
      //THIS IS THE PART I NEED HELP WITH *******
  
      //calculate pageNumber and index from the logical address
      int pageNumber = (logicalAddress/NbrOfPages);
      int index = (logicalAddress-(pageNumber*PageSize));
  
      //*****************************************
  
      //check if we get a pageFault
      if(pageTable[pageNumber]==-1){
          //call method to solve page fault
          pageFault(pageNumber);
          //the following two should be used in step 2 and 3 of the lab
          //pageFaultFIFO(pageNumber);
          //pageFaultLRU(pageNumber);
      }
      //read data from RAM
      int frame=pageTable[pageNumber];
      int physicalAddress=frame*PageSize+index;
      data=RAM[physicalAddress];
      //print result
      System.out.print("Virtual address: "+logicalAddress);
      System.out.print(" Physical address: "+physicalAddress);
      System.out.println(" Value: "+data);
      return data;
  }
  </code></pre>