Java Programming – Individual Assignment
Topic: Algorithm Design and Basic Decision Structures
1. Assignment Overview
This individual assignment focuses on algorithm design and basic decision-making
structures in Java. The objective is to help you develop logical thinking by designing
algorithms before implementing them in code.
You will practice representing algorithms using:
• Pseudocode
• Flowcharts
• Java code
The programming tasks will specifically focus on:
• Compound assignment operators (+=, -=, *=, /=, %=)
• Boolean operators (&&, ||, !)
• Single selection statements (if)
• Double selection statements (if–else)
Part 1 – Algorithm Design
Before writing Java code, algorithms must be expressed in pseudocode and flowcharts.
Task 1
Design an algorithm that:
1. Accepts a product price from the user.
2. If the price is greater than 100, apply a 10% discount.
3. Otherwise, the price remains unchanged.
4. Display the final price.
Requirements
You must provide:
1. Pseudocode
2. Flowchart
3. Java implementation
Task 2
Design an algorithm that:
1. Accepts a student's exam score.
2. If the score is greater than or equal to 50, display "PASS".
3. Otherwise, display "FAIL".
Requirements
You must provide:
1. Pseudocode
2. Flowchart
3. Java implementation
Part 2 – Compound Assignment Operators
Rewrite the following expressions using compound assignment operators.
Question 1
Convert the following statement:
total = total + price;
Using a compound assignment operator.
Question 2
Convert the following statement:
balance = balance - withdrawal;
Using a compound assignment operator.
Question 3
Convert the following statement:
points = points * 2;
Using a compound assignment operator.
Question 4
Convert the following statement:
number = number % 5;
Using a compound assignment operator.
Part 3 – Boolean Operators
For each condition, determine the result of the expression (True or False).
Question 5
int x = 10;
int y = 5;
(x > y) && (y < 3)
Explain the result.
Question 6
int a = 8;
int b = 8;
(a == b) || (a > 10)
Explain the result.
Question 7
int age = 20;
!(age < 18)
Explain the result.
Part 4 – Single Selection (if)
Write a Java program segment that:
Question 8
1. Reads a temperature value.
2. If the temperature is above 30, display:
Hot Weather
Question 9 (Challenging)
A user enters a bank account balance.
If the balance is below 0, display:
Account Overdrawn
Otherwise do nothing.
Part 5 – Double Selection (if–else)
Question 10
Write a program that:
1. Reads a number.
2. If the number is even, display "Even Number".
3. Otherwise display "Odd Number".
Question 11 (More Challenging)
A store provides free delivery if the purchase amount is greater than 75.
1. Read the purchase amount.
2. If the amount is greater than 75, display:
Free Delivery
3. Otherwise display:
Delivery Cost: 5
Question 12 (Advanced Logic)
A cinema provides student discounts.
Conditions:
• If age is less than 18 → Ticket price = 6
• Otherwise → Ticket price = 10
Write a Java program using if–else to determine and display the ticket price.
Part 6 – Algorithm Design Challenge
Question 13 (Complex Logic)
Design an algorithm that determines whether a person qualifies for a loan approval.
Conditions:
• Income must be greater than 2500
• AND credit score must be greater than 650
If both conditions are true:
Loan Approved
Otherwise:
Loan Denied
Requirements
You must provide:
1. Pseudocode
2. Flowchart
3. Java implementation
Submission Requirements
Students must submit one document containing:
1. Pseudocode for required questions
2. Flowcharts for required questions
3. Java code implementations
Formatting requirements:
• Use clear headings
• Flowcharts must be properly structured
• Java code must be properly indented
Academic Integrity
This is an individual assignment.
Students must complete their work independently.
Any form of copying or plagiarism will result in zero marks for the assignment.