Three Puget Sound area tech companies (Company A, Company B, Company C) have decided to hold...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Three Puget Sound area tech companies (Company A, Company B, Company C) have decided to hold an event to improve relations. Each company sends one engineer and one manager to go on a hike. The three engineers and three managers hike for an hour and eventually reach a river which they need to cross. There is a small boat where at most two people can fit at a time. Any person can pilot the boat. There is one caveat: If a manager is in the presence of an engineer of a different company when that engineer's manager is not present, the manager will feel obligated to recruit the engineer to join their company. However, this would ruin the event's synergy. Let's model the rules of this problem so that a player could try to solve the puzzle without violating the laws of physics or ruining the event. Create a class called ManagersCrossing. Inside that class, create a method with the following signature: public static boolean isMoveokay (int boatBefore, int managerABefore, int VaNagerRRefore, int panagerCBefore, int engineerABetere, int engineerBBetere, int engineerCBefore, int boatafter, int managerAAfter, int managerBAfter, int managerCAfteR, int engineerAAfter, int engineerBAfter, int engineeRGAfter) The boat and each of the six people have their own "Before" position parameter variable which is 1 if the position is on the left (original) side of the river and 2 if it is on the right (desired) side before the move. In addition, the boat and each of the six people have their own "After" position parameter which is 1 if the player wants the next position to be on the left side and 2 if they want it to be on the right side. Only a few positions can change in one move! Inside the isMovęokay method, you'll implement logic to check whether the After positions are compatible with the rules of the game compared with the Before positions. An overview of the logic follows. Note that at most one error message should be printed, and the order of the checks determines which error message to print. First, make sure that all parameter variables are 1 or 2. If not, print the following error message and return false: All positions must be 1 or 2! Second, make sure that the boat is changing position. If not, print the following error message and return false: The boat must move! Third, make sure that each person you're trying to move is on the same side as the boat. If not, print the following error message and return false: You may not move a person who is not with the boat! Fourth, make sure you're moving one or two people. If not, print the following error message and return false: You must move one or two people! Fifth, make sure that no manager would recruit anyone. There will be three separate checks, one for each manager A, B, and C, in that order. For each check, if a recruitment would happen, print the following error message, replacing X with A, B, or C as appropriate, and return false: Manager X would try to recruit someone! Finally, if none of the errors above occurred, check to see if the after positions solve the puzzle. If so, print: You solved the puzzle! If no errors occurred, you should return true to indicate that the move is okay. A tester program will test your code and provide helpful messages if there are problems! Three Puget Sound area tech companies (Company A, Company B, Company C) have decided to hold an event to improve relations. Each company sends one engineer and one manager to go on a hike. The three engineers and three managers hike for an hour and eventually reach a river which they need to cross. There is a small boat where at most two people can fit at a time. Any person can pilot the boat. There is one caveat: If a manager is in the presence of an engineer of a different company when that engineer's manager is not present, the manager will feel obligated to recruit the engineer to join their company. However, this would ruin the event's synergy. Let's model the rules of this problem so that a player could try to solve the puzzle without violating the laws of physics or ruining the event. Create a class called ManagersCrossing. Inside that class, create a method with the following signature: public static boolean isMoveokay (int boatBefore, int managerABefore, int VaNagerRRefore, int panagerCBefore, int engineerABetere, int engineerBBetere, int engineerCBefore, int boatafter, int managerAAfter, int managerBAfter, int managerCAfteR, int engineerAAfter, int engineerBAfter, int engineeRGAfter) The boat and each of the six people have their own "Before" position parameter variable which is 1 if the position is on the left (original) side of the river and 2 if it is on the right (desired) side before the move. In addition, the boat and each of the six people have their own "After" position parameter which is 1 if the player wants the next position to be on the left side and 2 if they want it to be on the right side. Only a few positions can change in one move! Inside the isMovęokay method, you'll implement logic to check whether the After positions are compatible with the rules of the game compared with the Before positions. An overview of the logic follows. Note that at most one error message should be printed, and the order of the checks determines which error message to print. First, make sure that all parameter variables are 1 or 2. If not, print the following error message and return false: All positions must be 1 or 2! Second, make sure that the boat is changing position. If not, print the following error message and return false: The boat must move! Third, make sure that each person you're trying to move is on the same side as the boat. If not, print the following error message and return false: You may not move a person who is not with the boat! Fourth, make sure you're moving one or two people. If not, print the following error message and return false: You must move one or two people! Fifth, make sure that no manager would recruit anyone. There will be three separate checks, one for each manager A, B, and C, in that order. For each check, if a recruitment would happen, print the following error message, replacing X with A, B, or C as appropriate, and return false: Manager X would try to recruit someone! Finally, if none of the errors above occurred, check to see if the after positions solve the puzzle. If so, print: You solved the puzzle! If no errors occurred, you should return true to indicate that the move is okay. A tester program will test your code and provide helpful messages if there are problems!
Expert Answer:
Answer rating: 100% (QA)
CODE package managerscrosing import javautilScanner public class ManagersCrosing static method isMoveOkay public static boolean isMoveOkayint boatBefore int managerABefore int managerBBefore int manag... View the full answer
Related Book For
Applied Regression Analysis and Other Multivariable Methods
ISBN: 978-1285051086
5th edition
Authors: David G. Kleinbaum, Lawrence L. Kupper, Azhar Nizam, Eli S. Rosenberg
Posted Date:
Students also viewed these accounting questions
-
? ? ? ?? Company A Cash Net Sales Revenue Finished Goods Inventory Cost of Goods Sold Selling Expenses Equipment Work-in-Process Inventory Accounts Receivable Cost of Goods Manufactured...
-
A small boat hangs from two davits, one of which is shown in the figure. The tension in line ABAD is 369 N. Determine the moment about C of the resultant force RA exerted on the davit at A. 24m
-
When a small boat travels north at 3 mi/h, a flag mounted on its stern forms s an angle = 50? with the centerline of the boat as shown. A short time later, when the boat travels east at 12 mi/h,...
-
Assuming 250 days of operation per year and a lead time of five days, what is the reorder point for Westside Auto in Problem 15? Show the general formula for the reorder point for the EOQ model with...
-
How many torr are in 2.443 atm?
-
For each of the following situations, (1) Indicate whether you agree or disagree with the financial reporting practice employed (2) State the basic assumption, pervasive constraint, or accounting...
-
Describe the role of an organizations personnel in compliance and antifraud efforts.
-
County Hospital orders syringes from a hospital supply firm. The hospital expects to use 40,000 per year. The cost to order and have the syringes delivered is $800. The annual carrying cost is $1.90...
-
Calculate whether the given matrices are diagonalizable or not. That is, for each matrix, calculate its eigenvalues and associates eigenvectors, then write down the P and D matrices such that AP = PD...
-
Not surprisingly, Tarek still has several thousand dollars in student loans outstanding. When he graduated from college, he had federal loans of $48,100, with an average APR of 5.40%. Six months...
-
Nissan Motor Company, Ltd. (Nissan) was by 1990 the world's fourth-largest automobile manufacturer. In 1990, Nissan produced just over 3 million vehicles, supplying approximately 10% of the world's...
-
In a recent accounting period, Ismail Company experienced a SAR30,000 unfavorable variance for variable production costs. Explain the meaning of an unfavorable variance.
-
A 0.20 kg pink ball is dropped vertically from rest from 1.5m on to the soft ground. It sinks 0.05m into the ground while stopping. what quantities can you determine before the ball hits the ground?
-
You are a CPA working in the tax group of your firm. Zhihong ("Zhi") has been a client of the firm for a number of years. He has approached the partner on his engagement with two issues that will...
-
L 3. Artificial neural network (ANN) is a biologically motivated learning model. Constituent building blocks are neurons that uses an activation function over weighted summation of input. Choice of...
-
Consider the following training data consisting of three features X, X and x3 and the class attribute Y that I could be Red, White, or Black.
-
As part of the process, scientists will transport containers of supplies, tools and machinery so that they are waiting for the colonists when they arrive. The first container shipped has a mass of...
-
The population of Detroit, Michigan, decreased from 1,027,974 in 1990 to 688,701 in 2013 (Source: U.S. Census Bureau). Find the average rate of change in the population of Detroit, Michigan, over the...
-
In an analysis of daily soil evaporation (EVAP), Freund (1979) identified the following predictor variables: MAXAT = Maximum daily air temperature MINAT = Minimum daily air temperature AVAT =...
-
A panel of educators in a large urban community wanted to evaluate the effects of educational resources on student performance. They examined the relationship between 12th-grade mean math SAT scores...
-
For the data given in Problem 4 in Chapter 8 (plus the accompanying computer output), find (using = .10) the best regression model relating homicide rate (Y) to population size (X1), percentage of...
-
During the initiation stage of translation in bacteria, which of the following events occur(s)? a. IF1 and IF3 bind to the 30S subunit. b. The mRNA binds to the 30S subunit, and tRNAfMet binds to the...
-
Each ribosomal subunit is composed of a. multiple proteins. c. tRNA. b. rRNA. d. both a and b.
-
An inborn error of metabolism is caused by a. a mutation in a gene that causes an enzyme to be inactive. b. a mutation in a gene that occurs in somatic cells. c. the consumption of foods that disrupt...
Study smarter with the SolutionInn App