0% found this document useful (0 votes)
4 views5 pages

Java Exercises

The document outlines a series of programming tasks designed to teach basic Java concepts, including arithmetic operations, conditionals, arrays, and input handling. Each task includes a description, objectives, and the relevant Java concepts to be utilized. The tasks range from simple arithmetic calculations to creating a grading system based on user input.

Uploaded by

neshelle.llagas
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)
4 views5 pages

Java Exercises

The document outlines a series of programming tasks designed to teach basic Java concepts, including arithmetic operations, conditionals, arrays, and input handling. Each task includes a description, objectives, and the relevant Java concepts to be utilized. The tasks range from simple arithmetic calculations to creating a grading system based on user input.

Uploaded by

neshelle.llagas
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

Name: Neshelle P.

Llagas Section: EG1

Task 1: Simple Arithmetic

Description:
Write a Java program that asks the user to input two numbers and prints:

• Sum
• Difference
• Product
• Quotient

Concepts: Scanner, arithmetic operators (+ - * /)

CODE SNIPPET:

OUTPUT:
Task 2: Even or Odd Checker

Objective: Learn conditionals and modulus operator.

Description:
Write a program that reads a number from the user and prints whether it is even or odd.

Concepts: if-else, % operator

CODE SNIPPET:

OUTPUT:
Task 3: Favorite Fruits List

Objective: Learn about arrays/ArrayList and loops.

Description:
Create an ArrayList to store 5 favorite fruits. Display all the fruits using a loop.

Concepts: ArrayList, for-each loop

CODE SNIPPET:

OUTPUT:
Task 4: Name and Age Calculator

Objective: Combine input, variables, and basic arithmetic.

Description:
Write a program that asks the user for their name and birth year, then calculates and prints:

Hello [name]! You are [age] years old.

Concepts: Scanner, variables, arithmetic, [Link]

CODE SNIPPET:

OUTPUT:
Task 5: Simple Grading System

Objective: Learn conditionals and logical operators.

Description:
Write a program that asks the user for a score (0–100). Print the grade based on the score:

• 90–100: A
• 80–89: B
• 70–79: C
• 60–69: D
• Below 60: F

Concepts: if-else if-else, logical operators (&&)

CODE SNIPPET:

OUTPUT:

You might also like