Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem: Alex is a sales manager in an organization that sells 10 products. Each products sales information is available in separate files (that means there

Problem: Alex is a sales manager in an organization that sells 10 products. Each products sales information is available in separate files (that means there are 10 files for 10 products). Alex can keep at most 5 files on his table at a time. The currently used file is always kept on the top of the file stack on his table. When a file is required, he checks his table first. He keeps it on the top of the file stack if available. Otherwise, he fetches it from the file rack and keeps it on the top of the file stack. In the second case, if the file stack already contains 5 files, Alex returns the bottom-most file to the rack. Write a Java program to implement this situation using an integer array of 5 cells which keeps track of the files currently in the file stack on Alexs table. Procedure: Assume that the 10 product files can be identified by their number, i.e., 1, 2, 10. Also, assume that the first cell of the array represents the top of the file stack. i) Ask the user for a file (just the number). ii) Check whether that file is already available in the array. If its available, bring it to the first cell of the array if it is not there. Apply array shifting operation to do so. iii) If the file is not in the array, insert it in the first cell. iv) While inserting a new file in the array, the last file will be automatically removed if the array is full. Print which file is returned to the rack. v) Show the content of the array after every operation.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+1. What are sensation and perception?

Answered: 1 week ago