Skip to content

nurulashraf/java-loops-and-conditionals-exercises

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Java Loops and Conditionals Exercises

This repository contains a collection of exercises focused on Java programming, specifically designed to practice loops and conditionals. These exercises will help learners improve their understanding of these fundamental programming concepts in Java.

Table of Contents

Installation

To get started with these exercises, follow these steps:

  1. Clone this repository to your local machine using the following command:

    git clone https://github.com/nurulashraf/java-loops-and-conditionals-exercises.git
  2. Navigate into the directory:

    cd java-loops-and-conditionals-exercises
  3. Ensure you have Java Development Kit (JDK) installed on your machine. If not, download it from here.

  4. To compile and run any of the Java exercises, open your terminal or command prompt in the corresponding exercise folder and use the following commands:

    javac ExerciseName.java
    java ExerciseName

Usage

The repository includes various Java exercises that demonstrate loops (for, while, do-while) and conditional statements (if, else, switch). Each exercise is contained within its own Java file. You can edit, compile, and run them independently.

Example:

  1. Navigate to a specific exercise:
    cd Exercise1
  2. Compile and run:
    javac Exercise1.java
    java Exercise1

Exercises

The following exercises are included:

  1. Exercise 1: For loop to print numbers from 1 to 10.
  2. Exercise 2: While loop to find the factorial of a number.
  3. Exercise 3: Use of if-else to check whether a number is even or odd.
  4. Exercise 4: Switch case to display a day of the week based on user input.
  5. Exercise 5: Do-while loop to reverse a number.

Each exercise has comments to guide you through the code and explain the concepts used.

Contributing

Contributions are welcome! If you would like to contribute to this repository, feel free to fork it, make changes, and submit a pull request. Here are some ways you can help:

  • Improve existing exercises or add new ones.
  • Provide explanations and comments for better clarity.
  • Report any issues you find.

License

This repository is licensed under the MIT License.

About

This repository contains Java exercises on control flow, including loops (for, while, do-while) and conditional statements (if, else, switch). The exercises are designed to help beginners practice and strengthen their understanding of Java's fundamental control structures. Each exercise is well-organized for easy learning.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages