Implement stacks in both Java and Python. You can use online java compiler IDE or netbeans.
Extracted text: 1. Import Scanner and Stacks from the java.util package. 2. Create a Stack object named basket. 3. The output shall: 3.1. Ask the user to input the number of fruits s/he would like to catch. 3.2. Ask the user to choose a fruit to catch by pressing A for apple, O for orange, M for mango, or G for guava. 3.3. Display all the fruits that the basket has. 3.4. Ask the user to enter E to start eating a fruit. 3.5. Display the fruits remaining each time E is entered and "No more fruits" when the basket becomes empty. 4. Convert your code into a Python script. Use the range) function to allow the userto input multiple times. Forexample, if the user has to enterinput five (5) times, the code will be for i in range(5). The variable i re presents numbers 1 to 5. Since the user input is only a one-character string, refer to the samplecode belowto add afruitto the basket. The variablei represents allthe one-character strings entered by the user. The functions upper0 and lower) allow case-insensitive input. for i In keys: If Lupper() "A": bask et. append ("apple") == 5. Save the script as fruit_basket.py to your folder. See sample output for Python on the next pge. Catch and eat any of these fruits:("apple', 'orange', 'mango', 'guava') How many fruits would you like to catch? 4 Choose a fruit to catch. Press A, o, M, or G. Fruit 1 of 4: m Fruit 2 of 4: o Fruit 3 of 4: a Fruit 4 of 4: a Your basket now has: ['mango', 'orange', 'apple', 'apple'] Press E to eat a fruit. e Fruit(s) in the basket: ['mango', 'orange', 'apple'] Press E to eat a fruit. e Fruit(s) in the basket: ['mango', 'orange'] Press E to eat a fruit. e Fruit(s) in the basket: ['mango'] Press E to eat a fruit. e INo more fruits
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here