1. Efficient Janitor The janitor of a high school is extremely efficient. By the end of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Efficient Janitor The janitor of a high school is extremely efficient. By the end of each day, all of the school's waste is in plastic bags weighing between 1.01 pounds and 3.00 pounds. All plastic bags are then taken to the trash bins outside. One trip is described as selecting a number of bags which together do not weigh more than 3.00 pounds, dumping them in the outside trash can and returning to the school. Given the number of plastic bags n, and the weights of each bag, determine the minimum number of trips the janitor has to make. Example n = 5 weight = [1.01, 1.99, 2.5, 1.5, 1.01] The janitor can carry all plastic bags out in 3 trips: [1.01 +1.99, 2.5, 1.5 +1.01]. Function Description Complete the function efficientjanitor in the editor below. efficientjanitor has the following parameter(s): float weight[n]: weights of the bags Returns int: the minimum number of trips required Constraints 1 ≤n≤ 1000 1.01 ≤ weight[i] ≤ 3.0 Input Format For Custom Testing The first line contains an integer, n, the number of elements in weight. Each line i of the n subsequent lines (where 0≤i<n) contains a floating point number that describes weight[i]. ▾ Sample Case 0 Sample Input For Custom Testing STDIN Function 5 →weight [] size n = 5 1.01 → weight = [1.01, 1.01, 1.01, 1.4, 2.4] 1.01 1.01 1.4 2.4 Sample Output 3 Explanation The janitor can carry all plastic bags out in 3 trips: The first 2 plastic bags together, the 3rd and 4th together and the last one alone ▾ Sample Case 1 Sample Input For Custom Testing Function STDIN 4 → weight [] size n = 4 1.01 →weight = [1.01. 1.991, 1.32, 1.4] 1.991 1.32 1.4 Sample Output 3 Explanation The janitor can carry all plastic bags out in 3 trips: The 1st and 2nd plastics bags separately and the 3rd and 4th together 1. Efficient Janitor The janitor of a high school is extremely efficient. By the end of each day, all of the school's waste is in plastic bags weighing between 1.01 pounds and 3.00 pounds. All plastic bags are then taken to the trash bins outside. One trip is described as selecting a number of bags which together do not weigh more than 3.00 pounds, dumping them in the outside trash can and returning to the school. Given the number of plastic bags n, and the weights of each bag, determine the minimum number of trips the janitor has to make. Example n = 5 weight = [1.01, 1.99, 2.5, 1.5, 1.01] The janitor can carry all plastic bags out in 3 trips: [1.01 +1.99, 2.5, 1.5 +1.01]. Function Description Complete the function efficientjanitor in the editor below. efficientjanitor has the following parameter(s): float weight[n]: weights of the bags Returns int: the minimum number of trips required Constraints 1 ≤n≤ 1000 1.01 ≤ weight[i] ≤ 3.0 Input Format For Custom Testing The first line contains an integer, n, the number of elements in weight. Each line i of the n subsequent lines (where 0≤i<n) contains a floating point number that describes weight[i]. ▾ Sample Case 0 Sample Input For Custom Testing STDIN Function 5 →weight [] size n = 5 1.01 → weight = [1.01, 1.01, 1.01, 1.4, 2.4] 1.01 1.01 1.4 2.4 Sample Output 3 Explanation The janitor can carry all plastic bags out in 3 trips: The first 2 plastic bags together, the 3rd and 4th together and the last one alone ▾ Sample Case 1 Sample Input For Custom Testing Function STDIN 4 → weight [] size n = 4 1.01 →weight = [1.01. 1.991, 1.32, 1.4] 1.991 1.32 1.4 Sample Output 3 Explanation The janitor can carry all plastic bags out in 3 trips: The 1st and 2nd plastics bags separately and the 3rd and 4th together
Expert Answer:
Answer rating: 100% (QA)
We use Scanner class to take user input The function void readBagsWeight take user input the weights ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
In the senior year of a high school graduating class of 100 students, 42 studied mathematics, 68 studied psychology, 54 studied history, 22 studied both mathematics and history, 25 studied both...
-
In 2009 the average earnings of a high school graduate were $32,272. At $62,394, the average earnings of a recipient of a bachelors degree were about 93% higher. (a) Construct a misleading graph that...
-
In 2013, the average earnings of a high school graduate were $30,286. At $50,738, the average earnings of a recipient of a bachelor's degree were about 66% higher. (a) Construct a misleading graph...
-
The functions in Exercises 1128 are all one-to-one. For each function, a. Find an equation for f -1 (x), the inverse function. b. Verify that your equation is correct by showing that f( f -1 (x)) = x...
-
Compute key ratios and other financial measures for Crazy Eddie during the period 19841987. Identify and briefly explain the red flags in Crazy Eddies financial statements that suggested the firm...
-
A company that manufactures recreational pedal boats has approached Mike Cichanowski to ask if he would be interested in using Current Designs rotomold expertise and equipment to produce some of the...
-
True or False: If \(\operatorname{IRR}(\mathrm{A})>\operatorname{IRR}(\mathrm{B})\), then \(\operatorname{ERR}(\mathrm{A})>\operatorname{ERR}(\mathrm{B})\).
-
The following are selected transactions of Blanco Company. Blanco prepares financial statements quarterly. Jan. 2 Purchased merchandise on account from Nunez Company, $30,000, terms 2/10, n/30....
-
Explain using examples why partial equilibrium is a useful tool for agricultural economists and discus its shortcomings as a tool for policy analysis.
-
Tree Seedlings has the following current-year purchases and sales for its only product. Date January 1 January 3 February 14 February 15 June 30 November 6 November 19 Activities Beginning inventory...
-
What is the de Broglie wavelength of a nitrogen molecule in air at 300 K? Assume that the molecule is moving with the root-mean square speed of molecules at this temperature. (Atomic mass of nitrogen...
-
You are an entrepreneur starting a biotechnology firm. If your research is successful, the technology can be sold for $21 million. If your research is unsuccessful, it will be worth nothing. To fund...
-
Slow n Steady, Inc., has a stock price of $34, will pay a dividend next year of $3.25, and has expected dividend growth of 1.3% per year. What is your estimate of Slow n Steadys cost of equity...
-
Assume that Microsoft has a total market value of $303.9 billion and a marginal tax rate of 35%. If it permanently changes its leverage from no debt by taking on new debt in the amount of 13% of its...
-
Avicorp has a $13.4 million debt issue outstanding, with a 6.2% coupon rate. The debt has semiannual coupons, the next coupon is due in six months, and the debt matures in five years. It is currently...
-
Braxton Enterprises currently has debt outstanding of $5 million and an interest rate of 8%. Braxton plans to reduce its debt by repaying $1 million in principal at the end of each year for the next...
-
A Peruvian company that exports citrus to the US expects to receive a payment in US$ within 60 days. The company wants to hedge against the exchange risk, whose current level is 3.75 PEN/US$. The...
-
Why do bars offer free peanuts?
-
Your firm relies heavily on temporary workers. To minimize potential legal issues, it ensures that the temporary workers are not mistaken about their place within the com-pany. Therefore, temporary...
-
1. Imagine that your grandmother has suffered from asthma all her life and within the past year was diagnosed with type II diabetes. She has been quite depressed as she must now be extremely careful...
-
A coworker complains to you that he is sick of seeing the company pollute the waters of a nearby stream by dumping runoff water into it from the manufacturing process. He plans to send an anonymous...
-
Copeland Hotels Ltd provide three levels of rooms in their hotels. The following planning data are provided for the year ended 31 December 2020: Fixed hotel overhead costs are $24 360 000 per year,...
-
Define and give examples of relational needs, identity needs, informational needs, and instrumental needs that communication can help us meet.
-
Come up with a statement that you might say to a supervisor and explain how its content dimension and relational dimension might differ.
Study smarter with the SolutionInn App