exampleLoops

Educational code samples demonstrating basic loop structures in Java and Python.

https://github.com/davidbmar/exampleLoops  ·  public  ·  shipped

What it is

A minimal educational repository containing implementations of a simple multiplication table generator. It solves a specific algorithmic task: given an integer n, print the first 10 multiples of n using iterative loops. The project serves as a reference for syntax comparison between Java and Python.

Features

Quickstart

javac Solution.java
java Solution
python3 loops.py

Architecture

flowchart TD
    A[User Input] -->|Integer n| B(Main Execution)
    B --> C{Loop Counter 1-10}
    C -->|Yes| D[Calculate n * counter]
    D --> E[Print Formatted String]
    E --> C
    C -->|No| F[Exit]

How it's built

The Java implementation uses the java.util.Scanner class for standard input parsing and a standard for-loop for iteration. The logic calculates products sequentially and prints formatted strings to stdout. The Python implementation (implied by description) follows similar logic using Python's range-based looping constructs.

How it runs

sequenceDiagram
    participant User
    participant Main as Solution.main()
    participant Scanner as java.util.Scanner
    participant Console as System.out
    
    User->>Main: Provide integer n
    Main->>Scanner: nextInt()
    Scanner-->>Main: Return n
    
    loop counter = 1 to 10
        Main->>Main: Calculate answer = n * counter
        Main->>Console: println(n + " x " + counter + " = " + answer)
    end

How to apply & reuse

Use this repository as a baseline for teaching introductory programming concepts, specifically iteration and standard I/O. It is suitable for beginners learning syntax differences between statically typed (Java) and dynamically typed (Python) languages.

At a glance

CapabilitiesStandard input parsingIterative calculationFormatted console output
ComponentsSolution.javaloops.py
TechJavaPython
Depends onJDK 8+Python 3.x
Integrates with
PatternsFor LoopStandard I/OLinear Iteration
Reuse tagseducationbeginnerloopssyntax-comparison

Repo hygiene

✓ all on main — nothing unmerged.