Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLEASE HELP IN JAVA!!! Multi-Level Feedback Queue CPU Level 1-FIFO Use CPLU Leve

ID: 3597075 • Letter: P

Question

PLEASE HELP IN JAVA!!!

Multi-Level Feedback Queue CPU Level 1-FIFO Use CPLU Level 2-FIFO Use CPU Level 3-FIFO Use CPU Level n-round robin Use CPLU In the multi-level feedback scheme, the quantum given to processes as they move to each lower level queue becomes larger. Thus, the longer a process has been in the queuing network, the larger quantum it is assigned each time it gets the CPU. But it may not get the CPU very often because processes in the higher queues are given higher priority. A process in a given queue cannot run unless all higher-level queues are empty. A process can also be preempted by a new process entering the queuing system. In this way, new processes enter the network with very high priority and get fast service if they are either interactive orO bound. Processes that are CPU bound consume their full quantum, unless preempted, and then are placed at the rear of the next lower-priority queue. The longer a process uses the CPU, the lower its

Explanation / Answer

import java.util.Scanner; public class Game { private Player p1; private Player p2; private Dice dice; private int scoreToWin; void displayGameMenu() { System.out.println(); System.out.println("(1) Start a new game"); System.out.println("(2) Play one round"); System.out.println("(3) Who is leading now?"); System.out.println("(4) Display game help"); System.out.println("(5) Exit game"); System.out.print("Choose an option: "); } void selectGameOption(int optionSelected) { switch (optionSelected) { case 1: this.startNewGame(); break; case 2: this.playOneRound(p1); this.playOneRound(p2); break; case 3: this.whoIsLeading(); break; case 4: this.displayGameInstruction(); break; default: break; } } void startNewGame() { String p1Name; String p2Name; Scanner sc = new Scanner(System.in); System.out.print("Please enter player one name: "); p1Name = sc.nextLine(); System.out.print("Please enter player two name: "); p2Name = sc.nextLine(); System.out.print("Please enter the maximum score required to win: "); scoreToWin = sc.nextInt(); p1 = new Player(p1Name); p2 = new Player(p2Name); dice = new Dice(); } void playOneRound(Player p) { int result; int firstDiceRoll = dice.rollDice(); int secondDiceRoll = dice.rollDice(); if (firstDiceRoll == secondDiceRoll) { result = (firstDiceRoll + secondDiceRoll) * 2; p.setTotalScore(result); System.out.printf("%s rolled %d and %d, " + "and scored %d points(BONUS DOUBLE POINTS), " + "for a total of %d points", p.getName(), firstDiceRoll, secondDiceRoll, result, p.getTotalScore() ); } else { result = (firstDiceRoll + secondDiceRoll); p.setTotalScore(result); System.out.printf("%s rolled %d and %d, " + "and scored %d points, " + "for a total of %d points", p.getName(), firstDiceRoll, secondDiceRoll, result, p.getTotalScore() ); } System.out.println(); } void whoIsLeading() { if (p1.getTotalScore() == p2.getTotalScore()) { System.out.format("Its currently a draw, " + "%s has %d, %s has %d", p1.getName(), p1.getTotalScore(), p2.getName(), p2.getTotalScore() ); } else if (p1.getTotalScore() > p2.getTotalScore()) { System.out.printf("%s is leading, %s has %d points, " + "%s has %d points", p1.getName(), p1.getName(), p1.getTotalScore(), p2.getName(), p2.getTotalScore()); } else if (p1.getTotalScore() = scoreToWin && p2.getTotalScore() >= scoreToWin) { System.out.println("Its a draw! Both players have exceeded the score limit"); return true; } else if (p1.getTotalScore() >= scoreToWin && p2.getTotalScore() 5 || optionSelected < 0) { System.out.print("Option entered invalid, please enter a number from 1 to 5: "); optionSelected = sc.nextInt(); } if (optionSelected == 5) { System.out.println("Exiting game"); break; } game.selectGameOption(optionSelected); boolean anyoneWin = game.checkIfAnyoneHasWon(); if (anyoneWin) { System.out.println(); System.out.println("Game ended."); break; } } } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote