0% found this document useful (0 votes)
691 views2 pages

Hands-On Activity Fruit Basket: Objective

This document provides instructions for a hands-on activity to implement stacks in Java and Python. Students will create a fruit basket program that uses a stack to add and remove fruits. The program will ask the user to input the number of fruits to catch and choose a fruit by key press. It will display the basket contents and allow the user to "eat" fruits, displaying the remaining fruits until the basket is empty. Students are to create the program in Java using NetBeans then convert it to a Python script using range() to allow multiple user inputs. The grading rubric evaluates correctness, logic, efficiency, and syntax.

Uploaded by

DARA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
691 views2 pages

Hands-On Activity Fruit Basket: Objective

This document provides instructions for a hands-on activity to implement stacks in Java and Python. Students will create a fruit basket program that uses a stack to add and remove fruits. The program will ask the user to input the number of fruits to catch and choose a fruit by key press. It will display the basket contents and allow the user to "eat" fruits, displaying the remaining fruits until the basket is empty. Students are to create the program in Java using NetBeans then convert it to a Python script using range() to allow multiple user inputs. The grading rubric evaluates correctness, logic, efficiency, and syntax.

Uploaded by

DARA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

IT1815

Hands-on Activity
Fruit Basket
Objective:

At the end of the exercise, the students should be able to:


▪ Implement stacks in both Java and Python.

Software Requirements:
▪ NetBeans IDE
▪ Java Development Kit (JDK) 8
▪ Python 3.7 or higher

Procedure:
1. Create a folder named LastName_FirstName in your local drive. (ex. Reyes_Mark)
2. Using NetBeans, create a Java project named FruitBasket. Set the project location to your own
folder.
3. Import Scanner and Stacks from the java.util package.
4. Create a Stack object named basket.
5. The output shall:
5.1. Ask the user to input the number of fruits s/he would like to catch.
5.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.
5.3. Display all the fruits that the basket has.
5.4. Ask the user to enter E to start eating a fruit.
5.5. Display the fruits remaining each time E is entered and "No more fruits" when the basket
becomes empty.
6. Convert your code into a Python script. Use the range() function to allow the user to input multiple
times. For example, if the user has to enter input five (5) times, the code will be for i in range(5).
The variable i represents numbers 1 to 5. Since the user input is only a one-character string, refer
to the sample code below to add a fruit to the basket. The variable i represents all the one-character
strings entered by the user. The functions upper() and lower() allow case-insensitive input.
for i in keys:
if i.upper() == "A":
basket.append("apple")
7. Save the script as fruit_basket.py to your folder.

See sample output for Python on the next page.

04 Hands-on Activity 1 *Property of STI


Page 1 of 2
IT1815

GRADING RUBRIC (100 points):


Criterion Description Max Points
Correctness The code produces the expected result. 40
Logic The code meets the specifications of the problem. 40
Efficiency The code is concise without sacrificing correctness and logic. 10
Syntax The code adheres to the rules of the programming language. 10

04 Hands-on Activity 1 *Property of STI


Page 2 of 2

You might also like