Write a Java program that prompts the user for the page size used in a virtual memory system; this will be a power of two between 512 (29) and 16384 (214), inclusive. Your program should check the user input for page size to make sure it is one of the allowable inputs (must be a power of 2 and cannot be smaller than 512 or larger than 16384), and should then prompt the user for a virtual address (assume 32-bit virtual addressing, so your code must be able to accept any input between 0 and 4294967295, which is 232-1). Given this input, the program must output the virtual page number and the offset within the page. Sample output might look like this: Please enter the system page size: 1024 Please enter the virtual address: 10000 This address is in virtual page: 9 At offset: 784

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter12: Points, Classes, Virtual Functions And Abstract Classes
Section: Chapter Questions
Problem 19SA
icon
Related questions
Topic Video
Question

Write a Java program that prompts the user for the page size used in a virtual memory system; this will be a power of two between 512 (29) and 16384 (214), inclusive. Your program should check the user input for page size to make sure it is one of the allowable inputs (must be a power of 2 and cannot be smaller than 512 or larger than 16384), and should then prompt the user for a virtual address (assume 32-bit virtual addressing, so your code must be able to accept any input between 0 and 4294967295, which is 232-1). Given this input, the program must output the virtual page number and the offset within the page. Sample output might look like this:

Please enter the system page size:

1024

Please enter the virtual address:

10000

This address is in virtual page:

9

At offset:

784

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 8 steps with 8 images

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning