Skip to content

ryankerbyIT/JavaArrayAnd2DArray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Array and 2D Array Challenges

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.

Table of Contents

1. Rainfall Class

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.

View the solution

2. Payroll Class

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.

View the solution

3. Charge Account Validation

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.

View the solution

4. Charge Account Modification

This is a modification of the Charge Account Validation program, where valid account numbers are read from a file instead of being hardcoded.

View the solution

5. Larger Than n

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.

View the solution

6. Driver's License Exam

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.

View the solution

7. Magic 8 Ball

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.

View the solution

8. Grade Book

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.

View the solution

9. Grade Book Modification

Modify the GradeBook class to drop the lowest test score for each student before calculating their average score and final letter grade.

View the solution

10. Average Steps Taken

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.

View the solution

11. Array Operations

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.

View the solution

12. 1994 Gas Prices

Read a file containing weekly gas prices for the year 1994 and calculate:

  • The lowest and highest prices.
  • The average price for each month.

View the solution

13. Sorted List of 1994 Gas Prices

Enhance the gas prices program to calculate the average gas price per month, then sort the list of months by their average gas price.

View the solution

14. Name Search

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.

View the solution

15. Population Data

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.

View the solution

16. World Series Champions

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.

View the solution

17. 2D Array Operations

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.

View the solution

18. Phone Book ArrayList

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.

View the solution

19. Trivia Game

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.

View the solution

20. Lo Shu Magic Square

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.

View the solution


How to Run the Programs

  1. Clone this repository:
    git clone https://github.com/ryankerbyIT/ArrayAnd2DArrayChallenges.git
    
    

Instructions:

  1. Copy and paste the above markdown into your README.md file.
  2. Replace the placeholder yourusername in the GitHub link with your actual GitHub username.
  3. 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!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages