0% found this document useful (0 votes)
3 views

Java Practice Problems

Uploaded by

nayeemwork124
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)
3 views

Java Practice Problems

Uploaded by

nayeemwork124
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/ 5

Java Programming Assignment:

Real-World Scenario Challenges


Assignment Overview
In this assignment, you'll solve programming challenges based on realistic scenarios. Each
problem requires you to apply Java programming concepts to solve practical problems.

Problem Scenarios
1. Student Grade Management System

Scenario: You are developing a grade tracking application for a small school.

Task: Create a method that takes “score” as input:

● Assigns a letter grade and status to students


● 90-100: "A - Excellent"
● 80-89: "B - Very Good"
● 70-79: "C - Satisfactory"
● 60-69: "D - Needs Improvement"
● Below 60: "F - Failed"
● Implement additional validation for impossible scores

Example:

Input: 85
Output: "B - Very Good"

2. Delivery Cost Calculator

Scenario: A local delivery company needs a system to calculate shipping costs based on
package weight.

Task: Develop a method calculateDeliveryCost(double weight) that:


● Charges $5 for packages up to 5 kg
● Adds $2 per kg over 5 kg
● Offers free shipping for packages under 2 kg
● Handles invalid weights (negative numbers)

Example:

Input: 7.5
Output: $9.00 (base $5 + $2 * 2.5 extra kg)

3. Inventory Stock Analyzer

Scenario: You're creating a stock management tool for a small electronics store.

Task: Write a method findMostStockedItem(int[] inventory) that:

● Takes an array of current stock levels


● Returns the highest stock quantity
● Provides additional information for low stock items

Example:

Input: [45, 12, 67, 23, 8]


Output: 67 (highest stock quantity)

4. Bank Account Security System

Scenario: Design a secure bank account management class for a local credit union, create
multiple accounts for different users and do such below operations.

Task: Create a BankAccount class with:

● Initial balance setup


● Account setup with name, address and phoneNumber
● Secure deposit method
● Withdrawal method with overdraft protection

Features:

● Prevent withdrawals below minimum balance


● Track total deposits and withdrawals
5. Pricing Calculator for Online Store

Scenario: Design a pricing method for an e-commerce platform.

Task: Create a method calculateFinalPrice(double basePrice, int quantity)


that:

● Applies bulk discounts


● 5-10 items: 10% off
● 11-20 items: 15% off
● Over 20 items: 20% off
● Handles edge cases and invalid inputs

Example:

Input: $50 base price, 12 items


Output: $510 (with 15% bulk discount)

6. Online Quiz Scoring System

Scenario: Design a quiz scoring mechanism for an online learning platform.

Task: Develop a method calculateQuizScore(int[] studentAnswers, int[]


correctAnswers) that:

● Uses a for loop to check student answers


● Calculates score based on correct responses
● Provides detailed answer analysis
● Implements partial scoring logic

Example:

Input:
- Student Answers: [1, 2, 3, 4, 5]
- Correct Answers: [1, 3, 3, 4, 6]
Output:
Total Score: 80%
Correct Answers: 4/5
7. Temperature Conversion Utility

Scenario: Create a temperature conversion tool for meteorological data.

Task: Write a method convertTemperatures(double[] celsius) that:

● Uses a for-each loop to convert temperatures


● Converts Celsius to Fahrenheit
● Identifies extreme temperatures
● Handles temperature anomalies

Example:

Input: [20.0, 25.5, 30.2, -5.0, 40.8]


Output:
Fahrenheit Conversions: [68.0, 77.9, 86.4, 23.0, 105.4]
Extreme Temperatures Detected: Lowest -5.0°C, Highest 40.8°C

8. Student Grade Analysis Tool

Scenario: Build a comprehensive grade analysis system for educators.

Task: Develop a method analyzeClassPerformance(int[] studentGrades) that:

● Uses while and do-while loops for advanced analysis


● Calculates multiple performance metrics
● Identifies grade distribution
● Provides comprehensive performance insights

Example:

Input: [85, 92, 67, 45, 88, 76, 91]


Output:
Average Grade: 77.4
Highest Grade: 92
Lowest Grade: 45
Grade Distribution:
A (90-100): 2 students
B (80-89): 2 students
C (70-79): 1 student
D (60-69): 1 student
F (0-59): 1 student
9.0Number Pyramid Pattern

Scenario: Create a number-based pyramid pattern.

Task: Develop printNumberPyramid(int height) that prints:

1
121
12321
1234321
123454321

10. Character Alphabet Pyramid

Scenario: Design an alphabet-based pyramid pattern.

Task: Develop printAlphabetPyramid(int height) that prints:

A
ABA
ABCBA
ABCDCBA
ABCDEDCBA

You might also like