Java_Lab_Activity_Family_Dependents.pptx

gwynethdiogracias1 0 views 6 slides Sep 21, 2025
Slide 1
Slide 1 of 6
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6

About This Presentation

Java Lab Activity, Looping Statements


Slide Content

Laboratory Activity: Dependents Java Programming - Looping Statements

Objectives 1. Apply looping statements (for, while, or do-while) in solving problems. 2. Use conditional statements inside loops to process input data. 3. Develop a simple Java program that computes results based on user input.

Instructions 1. Create a new Java program and save it as Dependents.java. 2. The program should: - Ask the user to enter the number of dependents. - For each dependent, ask for the name and age. - Assign an allowance based on age using if-else inside a loop: 0–5 years old → ₱1,000 allowance 6– 18 years old → ₱2,000 allowance Above 18 → ₱0 allowance - Display the total allowance for the family.

Sample Output Enter number of dependents: 3 Enter name of dependent 1: Ana Enter age of Ana: 4 Enter name of dependent 2: Ben Enter age of Ben: 10 Enter name of dependent 3: Carla Enter age of Carla: 19 Total Allowance: ₱3,000

Submission Guidelines • Submit your file as Dependents.java. • Make sure your code runs without errors. • Document your code with proper comments.

Reflection Questions 1. Which type of loop (for, while, or do-while) did you use? Why? 2. How did the loop make your program easier to write compared to not using a loop? 3. What changes would you make if the allowance rules were updated?
Tags