QuestionQuestion

There are 4 drawers in the copy machine.
Each have their own amount of papers in it.
The user will first select a drawer they want to print out of, if the number of copies they want to print exceeds that drawer, then the machine will continue printing the rest of the copies in the next drawer and so on (except when all drawers are empty, then it'll error: no more papers).
There's An array for each drawer with a certain amount of papers inside each. There is a max of 20 papers per drawer.
Also the Italicized numbers are the from the user):
'1' to print documents, "2' to load paper, '3' to get paper amount 1
Which drawer would you like to print from? 2
How much documents would you like to print? 7
1 copies printed from drawer 2
2 copies printed from drawer 2
3 copies printed from drawer 2
4 copies printed from drawer 2
5 copies printed from drawer 2
6 copies printed from drawer 3
7 copies printed from drawer 3

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

/*
* copyMachine class
*/
public class copyMachine {

private int[] drawers;
private int maxPaper;

// Constructor
public copyMachine(int numDrawers, int defaultPaper, int maxPaper) {
    this.drawers = new int[numDrawers];
    for (int i = 0; i < numDrawers; i++) {
      this.drawers[i] = defaultPaper;
    }
    this.maxPaper = maxPaper;
}

// Method to print paper
public void printPaper(int drawerNumber, int paperAmount) {
    int originalDrawer = drawerNumber;
    int count = 0;
    while (count < paperAmount) {
      if (this.drawers[drawerNumber-1] > 0) {
       count++;
       this.drawers[drawerNumber-1]--;
       System.out.println("Sheet #" + count + " printed from Drawer #" + drawerNumber + ".");
      } else {
       drawerNumber = (drawerNumber) % this.drawers.length + 1;
       if (drawerNumber == originalDrawer) {
          System.out.println("Printer Error: No more paper in the machine!");
          return...

By purchasing this solution you'll be able to access the following files:
Solution.PNG, Solution.java and Solution1.java.

$45.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats