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 time, in minutes, necessary to perform a certain task has the uniform [5, 9] distribution. a. Write the probability density function of this random variable. b. What is the probability that the...
-
What are the cultural patterns and values that underlie food choices in the United States, and how do they affect what you eat? Many fish have a smaller carbon footprint than livestock. However,...
-
Groups where the patterns of values outwardly reject those of the larger organization are ____________. (a) external adaptation rejectionist (b) cultural lag (c) countercultures (d) organizational...
-
For each of the following, indicate whether the statement is true or false and include a brief explanation for your answer. a. A pension trust fund appears in the government-wide financial statements...
-
Horizontal and vertical analysis dec 31 2022 accounts receivable 460,000 Inventory 780,000 Total Assets 3,164,000 Dec 31 2021 400,000 650,000 2,800,000
-
Chemco Inc. manufactures a combination fertilizer/weed-killer under the name Fertikil. It is the only product produced by Chemco at the present time. Fertikil is sold nationwide, through normal...
-
Identify 1 major health care legislation in the past 20 years that has had a significant impact on improving access, cost, and/or outcomes in the U.S. population. Describe the policy in terms of its...
-
What is patronage, and how does it affect the function of government? How did the merit system change the basis by which public employees were obliged to serve? What is evaluation and why is it an...
-
Libreras Gandhi and its advertising agency Ogilvy & Matter, which are known for promoting reading, won the EFFIE marketing award, given to the most creative campaigns and considered the most...
-
When used effectively, visuals help a writer or presenter convey information to their audience. For example, recently, British Columbia's (BC's) Public Health Officer, Dr. Bonnie Henry, and BC's...
-
Thomas Jefferson, who famously claimed that "all [human beings] are created equal," nevertheless owned slaves. What do you think are the best points that Benjamin Banneker made in his correspondence...
-
What is Net working capital? Can you provide examples from your work experience, or provide based on text reading? What is the relationship between net working capital and growth of the firm - will...
-
Standard Cost Journal Entries Bellingham Company produced 3,500 units that require six standard pounds per unit at a $3.5 standard price per pound. The company actually used 21,600 pounds in...
-
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 statements of financial position for Maxi Ltd and Mini Ltd are set out below. On 1 April last year, Maxi Ltd bought 1,500,000 shares of Mini Ltd for a total consideration of 5 million. At that...
-
A year ago Pod Ltd bought 225,000 1 fully paid ordinary shares of Pea Ltd for a consideration of 500,000. Pea Ltds share capital and share premium were each the same as at todays date. Simplified...
-
It has been suggested that too much information might be as bad as too little information for users of annual reports. Explain.
Study smarter with the SolutionInn App