Question

Please give me all necessary screenshot and comments. (I use Eclipse) Thanks Assume a system has...

Please give me all necessary screenshot and comments. (I use Eclipse) Thanks

Assume a system has 32-bit virtual memory address with a 4-KB page size. Write a program that is passed a virtual address (in decimal) and outputs the page number and offset for the given address.

The output should look like:

The address 19986 contains:

      Page number = 4

      Offset = 3602

Your driver should pass the program three numbers: 19986, 347892, and 5978.

Note the program will require using the appropriate data type to store 32 bits. Using an unsigned data type would be a good idea.

Place your program, observations file, and output file in the Dropbox for problem 4 in D2L. The observations should be in a separate attached word or data file. The output should be in a separate attached data file (do not give me a screen shot for your output).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

public class VirtualAddress {

public static void main(String[] args) {

// TODO Auto-generated method stub

Scanner sc = new Scanner(System.in);

System.out.println("Enter a number: ");

int number = sc.nextInt();

int temp = number;

int mask = 1 << 31;

StringBuilder sbuffer = new StringBuilder();

for (int i = 1; i <= 32; i++) {

sbuffer.append((number & mask) == 0 ? '0' : '1');

number = number << 1;

}

String vAddress = sbuffer.toString();

String pageNumber = vAddress.substring(0,vAddress.length()-12);

String offset = vAddress.substring(20);

System.out.println("The address "+ temp + " contains:");

System.out.println("Page number = " + Integer.parseInt(pageNumber,2));

System.out.println("Offset = " + Integer.parseInt(offset,2));

}

}

====================================================
SEE OUTPUT



Thanks, PLEASE COMMENT if there is any concern.

Add a comment
Know the answer?
Add Answer to:
Please give me all necessary screenshot and comments. (I use Eclipse) Thanks Assume a system has...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please use the python to write Assume that a system has a 32-bit virtual address with...

    Please use the python to write Assume that a system has a 32-bit virtual address with a 4-KB page size. Write a program that is passed a virtual address (in decimal) on the command line and have it output the page number and offset for the given address. As an example, your program would run as follows: ./addresses 19986 Your program would output: The address 19986 contains: page number = 4 offset = 3602 Writing this program will require using...

  • In C++ l. Assume that a system has a 32-bit virtual address with a 4-KB page...

    In C++ l. Assume that a system has a 32-bit virtual address with a 4-KB page size. Write a program that is passed a virtual address (in decimal) on the command line and have it output the page number and offset for the given address. As an example, your program would run as follows: yourprogram 19986 Your program would output: The address 19986 contains: Page number = 4 Offset = 3602 Writing this program will require using the appropriate data...

  • This is JAVA programing problem. Please give me all necessary screenshot and comments. (I use Ecl...

    This is JAVA programing problem. Please give me all necessary screenshot and comments. (I use Eclipse) Thanks Write a program that implements the FIFO, LRU, and Optimal page replacement algorithms presented in chapter 8 of your text. First generate a random page-reference string (this should be 20 entries long) where page numbers range from 0 to 9. Apply the random page-reference string to each algorithm, and record the number of page faults incurred by each algorithm. Implement the replacement algorithms...

  • Need help!! Java Eclipse Please provide the screenshot of output of code as well. thank you......

    Need help!! Java Eclipse Please provide the screenshot of output of code as well. thank you... PROGRAM 1 –Linear Data Structure Implementation (Due date: March 5th, 2019, 5% Grade Points) Given the starting point in a maze, you are to find and mark a path out of the maze which is represented by a 30x30 array of 1s (representing hedges) and 0s (representing the foot-paths). There is only one exit from the maze (represented by E). You may move vertically...

  • it’s from operating system. please provide me correct answer. A computer has 32-bit virtual addresses and...

    it’s from operating system. please provide me correct answer. A computer has 32-bit virtual addresses and 4-KB pages. The program and data together fit in the lowest page (0-4095) The stack fits in the highest page. How many entries are needed in the page table if traditional (one-level) paging is used? How many page table entries are needed for two-level paging, with 10 bits in each part? Submission: Upload a document with your calculations and results

  • Don't attempt if you can't attempt fully, i will dislike a nd negative comments would be...

    Don't attempt if you can't attempt fully, i will dislike a nd negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book tit le, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an...

  • Don't attempt if you can't attempt fully, i will dislike and negative comments would be given...

    Don't attempt if you can't attempt fully, i will dislike and negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book titnle, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an HTML web...

  • Hello, Please give me step by step solution (screenshot) on how to use the SPSS to...

    Hello, Please give me step by step solution (screenshot) on how to use the SPSS to solve the following: To examine the work environment on attitude toward work, an industrial hygienist randomly assigns a group of 18 recently hired sales trainees to three "home rooms" - 6 trainees per room. Each room is identical except for wall color. One is light green, another is light blue, and the third is a deep red. During the week-long training program, the trainees...

  • I need this in C programing And please give me complete code with screenshot of your...

    I need this in C programing And please give me complete code with screenshot of your output. onded reverze. e le defnes α node stricture identical to the list nodes for the cycle detection probem in Lab4 3. Cycle le removal (20 points). Implemeat the function break.cycleO in The prototype of the fnction s The function receives as its sole argment a poister to the the link that closwes the cycle, list. If the list contains a cycle the function...

  • C++ please Programming Assignment #6 Help Me Find The Secret Message Description: This assignment will require...

    C++ please Programming Assignment #6 Help Me Find The Secret Message Description: This assignment will require that you read in an encrypted message from a file, decode the message, and then output the message to a file. The encryption method being used on the file is called a shift cipher (Info Here). I will provide you with a sample encrypted message, the offset, and the decrypted message for testing. For this project I will provide you main.cpp, ShiftCipher.h, and ShiftCipher.cpp....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT