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...
-
The lifetime in months of a certain part has a gamma distribution with = = 2. A company buys three such parts and uses one until it fails, replacing it with a second part. When the latter fails, it...
-
A uniform rigid bar of mass \(m\) is connected to the wall of a trailer by a spring of stiffness \(k\) (see Fig. 5.64). The trailer has a mass \(5 m\), is connected to a spring of stiffness \(2 k\),...
-
How to obtain a temporary restraining order?
-
Suppose that we modify the Solow growth model by allowing long-run technological progress. That is, suppose that z = 1 for convenience, and that there is labor-augmenting technological progress, with...
-
How should Aspen ski resort account for the free skiing given to employees on their days off?
-
Case Introduction Established in 1967, Denns Fish House is a regional restaurant headquartered in a Southern US City, with dine-in buffet restaurants and several fast-food franchise locations....
-
Which of these would be an Act Discreditable to the profession by you under the Code of Professional Conduct? Withholding audit work papers that contain data, to which the client has no other access,...
-
5. Given the USART initialization subroutine below. Answer the following questions. Assume fosc = 8 MHz. void usart_init(void) { UCSRB (1
-
Nancy's son plans to start college when he graduates from High School. Assume that after-tax annual rate of return that Nancy is able to earn from her investment is 8.18 percent. The rate of...
-
Below shows the balance sheet, cash flow statement, and income statement of Uber Technologies, Inc. (ticker: UBER) in 2020 and 2021. (a) Calculate accounts payable turnover in 2020 and 2021....
-
What are the advantages of taking a company public? What are some of the benefits of staying private? Why would a borrower be attracted to lease financing? 2. Is preferred stock more like bonds or...
-
If the risk-free rate is 5%, the expected market risk premium (rm- rf ) is 10%, the firm has no debt, the equity beta of the firm is 2, the first dividend paid at t=1 is 11, and annual dividends...
-
Why should you set your own budget for buying a house, rather than using the amount provided by a loan officer?
-
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...
-
The boiling point diagram of a binary mixture can be represented with the help of the (a) Temperature versus volume plot (b) Pressure versus volume plot (c) Pressure versus composition plot (d)...
-
The criterion of phase equilibrium of a component is (a) \(d G_{T, P, V}=0\) (b) \(d G_{T, P}=1\) (c) \(d G_{T, P}=0\) (d) \(d A_{T, P}=0\).
-
The vapour-liquid equilibrium of a binary system can be better represented by (a) Temperature-composition \((T-X-Y)\) diagram (b) Pressure-composition \((P-X-Y)\) diagram (c) Pressure-temperature...
Study smarter with the SolutionInn App