This repository contains a collection of Java challenges focusing on arrays, 2D arrays, and basic algorithms. Each challenge is designed to strengthen your understanding of Java data structures and algorithms. The problems include examples of common operations like summing elements, finding minimums and maximums, and building simple applications like a trivia game.
- 1. Rainfall Class
- 2. Payroll Class
- 3. Charge Account Validation
- 4. Charge Account Modification
- 5. Larger Than n
- 6. Driver's License Exam
- 7. Magic 8 Ball
- 8. Grade Book
- 9. Grade Book Modification
- 10. Average Steps Taken
- 11. Array Operations
- 12. 1994 Gas Prices
- 13. Sorted List of 1994 Gas Prices
- 14. Name Search
- 15. Population Data
- 16. World Series Champions
- 17. 2D Array Operations
- 18. Phone Book ArrayList
- 19. Trivia Game
- 20. Lo Shu Magic Square
Create a Rainfall
class that stores the total rainfall for each month into an array of doubles. The program will include methods to:
- Return total rainfall for the year.
- Calculate the average monthly rainfall.
- Identify the month with the most and least rain.
The Payroll
class contains arrays to hold employee information such as employeeId
, hours
, and payRate
. The program calculates the gross pay for each employee based on hours worked and their pay rate.
This program validates charge account numbers. The user inputs an account number, and the program checks whether it matches any number in a predefined array of valid numbers.
This is a modification of the Charge Account Validation program, where valid account numbers are read from a file instead of being hardcoded.
Write a method that accepts an array of integers and a number n
. The method will display all numbers in the array that are larger than n
.
A class that simulates a driver’s license exam. The program stores correct answers and the student’s answers in arrays and calculates how many questions were answered correctly to determine if the student passes.
Simulate a Magic 8 Ball using a file containing 12 possible answers. The program reads from the file and randomly selects a response to display after the user asks a yes/no question.
A class that calculates the average score for students based on multiple test scores and assigns a letter grade. Each student’s name and scores are stored in arrays.
Modify the GradeBook
class to drop the lowest test score for each student before calculating their average score and final letter grade.
A program that reads from a file containing the number of steps taken each day over a year (365 days). It calculates and displays the average number of steps taken per month.
A class containing methods to:
- Get the total of all elements in an array.
- Get the average of all elements.
- Find the highest and lowest values in the array.
Read a file containing weekly gas prices for the year 1994 and calculate:
- The lowest and highest prices.
- The average price for each month.
Enhance the gas prices program to calculate the average gas price per month, then sort the list of months by their average gas price.
A program that reads the most popular boy and girl names from two files. It then allows the user to search for a name and checks if the name was in the top 200 most popular names.
Read population data from a file for the years 1950 to 1990. The program calculates the average annual population change and identifies the year with the largest and smallest population increases.
A program that reads a file containing World Series champions from 1903 to 2009. The user inputs a team’s name, and the program displays how many times the team has won the World Series.
Perform various operations on a 2D array, including calculating the total and average of all elements, row totals, column totals, and identifying the highest and lowest values in specific rows.
A program that stores PhoneBookEntry
objects in an ArrayList
. Each entry contains a person’s name and phone number. The program uses a loop to display the contents of the list.
A simple trivia game for two players. Each player answers 5 questions from a set of 10, with points awarded for correct answers. The player with the most points wins.
The program simulates a Lo Shu Magic Square, a 3x3 grid where the sum of each row, column, and diagonal is the same. The program checks if a 2D array is a valid Lo Shu Magic Square.
- Clone this repository:
git clone https://github.com/ryankerbyIT/ArrayAnd2DArrayChallenges.git
- Copy and paste the above markdown into your
README.md
file. - Replace the placeholder
yourusername
in the GitHub link with your actual GitHub username. - Adjust the file paths in the
[View the solution]
links to match the actual file locations in your repository.
Let me know if you need any additional changes or help!