Skip to content

ryankerbyIT/JavaLoops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Loops Projects in Java

This repository contains a collection of Java projects that demonstrate the use of different types of loops (for, while, do-while) and other related programming concepts. Each project focuses on applying loops to solve a specific problem.

Table of Contents

  1. Sum of Numbers
  2. Distance Traveled
  3. Distance File
  4. Pennies for Pay
  5. Letter Counter
  6. File Letter Counter
  7. Hotel Occupancy
  8. Average Rainfall
  9. Population Growth
  10. Largest and Smallest
  11. Celsius to Fahrenheit Table
  12. Bar Chart
  13. Dice Game
  14. Slot Machine Simulation
  15. Random Number Guessing Game
  16. ESP Game
  17. Square Display
  18. Personal Web Page Generator

1. Sum of Numbers

This program asks the user to enter a positive nonzero integer. It then calculates and displays the sum of all the numbers from 1 up to the entered value.

Usage:

javac SumOfNumbers.java
java SumOfNumbers

2. Distance Traveled

This program calculates the distance a vehicle travels for each hour of a given time period based on user input for speed and time.

Usage:

javac DistanceTraveled.java
java DistanceTraveled

3. Distance File

This is a modification of the Distance Traveled project. Instead of displaying the output to the console, the program writes the distance traveled for each hour to a text file.

Usage:

javac DistanceFile.java
java DistanceFile

4. Pennies for Pay

This program calculates the total salary earned over a given number of days if the salary starts with one penny and doubles each day. The output is shown in dollar format.

Usage:

javac PenniesForPay.java
java PenniesForPay

5. Letter Counter

This program asks the user to enter a string and a character. It counts and displays how many times the character appears in the string.

Usage:

javac LetterCounter.java
java LetterCounter

6. File Letter Counter

This program reads from a file, asks the user for a character, and then counts how many times the character appears in the file.

Usage:

javac FileLetterCounter.java
java FileLetterCounter

7. Hotel Occupancy

This program calculates the occupancy rate of a hotel by asking the user for the number of floors, rooms per floor, and the number of rooms that are occupied. It then calculates and displays the occupancy rate.

Usage:

javac HotelOccupancy.java
java HotelOccupancy

8. Average Rainfall

This program calculates the average rainfall over a given number of years by asking for rainfall data for each month.

Usage:

javac AverageRainfall.java
java AverageRainfall

9. Population Growth

This program predicts the size of a population based on an initial population size, a daily population growth rate, and the number of days for growth. The program uses loops to calculate the population growth over time.

Usage:

javac PopulationGrowth.java
java PopulationGrowth

10. Largest and Smallest

This program asks the user to enter a series of integers and determines the largest and smallest numbers in the series. The user enters -99 to indicate the end of input.

Usage:

javac LargestAndSmallest.java
java LargestAndSmallest

11. Celsius to Fahrenheit Table

This program displays a table converting Celsius temperatures from 0 to 20 to their Fahrenheit equivalents using a for loop.

Usage:

javac CelsiusToFahrenheit.java
java CelsiusToFahrenheit

12. Bar Chart

This program generates a simple bar chart based on sales figures entered for five stores. Each bar represents sales using asterisks, with each asterisk representing $100.

Usage:

javac BarChart.java
java BarChart

13. Dice Game

This is a simple game where the user competes against the computer by rolling dice. The game runs for 10 rounds, and the program keeps track of how many times each side wins.

Usage:

javac DiceGame.java
java DiceGame

14. Slot Machine Simulation

This program simulates a slot machine. The user enters an amount of money, and the program generates random results for a slot machine. If two or more results match, the user wins.

Usage:

javac SlotMachineSimulation.java
java SlotMachineSimulation

15. Random Number Guessing Game

The program generates a random number and allows the user to guess it. The user receives feedback whether the guess is too high or too low until they guess correctly.

Usage:

javac RandomNumberGuessingGame.java
java RandomNumberGuessingGame

16. ESP Game

This game tests the user’s ESP (extrasensory perception). The computer randomly selects a color from a list, and the user has to guess which color was selected.

Usage:

javac ESPGame.java
java ESPGame

17. Square Display

This program asks the user to enter a positive integer no greater than 15 and displays a square made of X characters of that size.

Usage:

javac SquareDisplay.java
java SquareDisplay

18. Personal Web Page Generator

This program asks the user for their name and a description. It generates a basic HTML page that displays this information.

Usage:

javac PersonalWebPageGenerator.java
java PersonalWebPageGenerator

How to Use

To run any of these programs:

  1. Clone the repository:
    git clone https://github.com/ryankerbyIT/JavaLoops.git
  2. Navigate to the specific project folder:
    cd path/to/project/folder
  3. Compile the .java file:
    javac FileName.java
  4. Run the program:
    java FileName

License

This project is licensed under the MIT License - see the LICENSE file for details.

Feel free to explore, modify, and improve upon these projects. Happy coding!

Releases

No releases published

Packages

No packages published