Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Function name: recycle() Parameters: number of soda bottles (int), number of grocery bags (int), number of plastic forks (int), number of bottle caps (int) Returns:
Function name: recycle() Parameters: number of soda bottles (int), number of grocery bags (int), number of plastic forks (int), number of bottle caps (int) Returns: string Description: You and your friends are walking on the beach, and sadly, you see plastic all over the shore. You decide to pick up all of the plastic so you can recycle it! However, before you can recycle it, it needs to be sorted. You will group all of the items you find by their Type of plastic. Then you will need to determine the number of items and total weight for each Type of plastic category. (See Rules for Sorting) After you have finished sorting, the recycling center asks that you bag all of the items. The recycling center provides you with three different bags, each determined by the type of plastic, number of items for each type, and total weight. (See Rules for Bagging) You want to count the final number of items in each bag and returns them out in the following format: Green: (num of items), Yellow: (num of items), Red: (num of items) Rules for Sorting: Item Type of plastic Item Weight An Empty Soda Bottle PETE (1) Grocery Bag | HDPE (2) Plastic Fork PP (5) Bottle Caps PP (5) 37.3 grams 5 grams 2.5 grams 2.4 grams Rules for Bagging: Green Bag: Type: PETE, Number of Items: 60 grams Type: PP, Number of Items: > 10, Total Weight: > 60 grams Yellow Bag: Type: PETE, Number of Items: > 5, Total Weight: > 60 grams Type: HDPE (All) Type: PP, Total Weight: 60 grams Test Cases: >>> recycle(2,1,0,1) Green:2, Yellow:2, Red:0 >>> recycle(1,0,3,3) Green:0, Yellow:6, Red:1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started