Skip to content

YuriiJavaDev/JavaBasics_Task_46_V0.1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Cinema Seats (JavaBasics_Task_46_V0.1)

📖 Description

This project simulates the display of available seating in a cinema row. It utilizes a While Loop to iterate through seat numbers starting from 2, incrementing by 2, until reaching the limit of 10.

The goal is to understand loop control with custom step increments and inclusive boundary conditions.

📋 Requirements Compliance

Task 46: Output seat numbers starting from 2, with a step of 2, up to 10 inclusive.

Requirements:

  • Initialize an int variable for the seat number.
  • Use a while loop that continues until the seat number is less than or equal to 10.
  • Print each seat number on a new line.
  • Increment the seat number by 2 in each iteration.

🚀 Architectural Stack

  • Conditional Iteration: Implementation of logic that handles specific numerical ranges.
  • Arithmetic Incrementation: Using the addition assignment operator (+=) to manage step logic.
  • Boundary Control: Effective use of the "less than or equal to" (<=) operator to ensure the final value is processed.

🏗️ Implementation Details

  • Logic Flow: The loop starts at 2, checks if it's within the range, prints, and jumps directly to the next even number.
  • Efficiency: By incrementing by 2 instead of checking every number with an if statement, the loop performs fewer iterations.

🛠 Features

  • Even Number Sequence: Automatically generates a list of even values within a set range.
  • Inclusive Logic: Correctly identifies and outputs the upper limit (10) as per requirements.
  • Minimalistic Design: Achieves the result with a single variable and straightforward loop logic.

📋 Expected result

2
4
6
8
10

💻 Code Example

Project Structure:

src/com/yurii/pavlenko/
                └── CinemaSeats.java # Main Entry Point & Logic

Code

package com.yurii.pavlenko;

public class CinemaSeats {
    public static void main(String[] args) {
        int seatNumber = 2;

        while (seatNumber <= 10) {
            System.out.println(seatNumber);
            seatNumber += 2;
        }
    }
}

⚖️ License

This project is licensed under the MIT License.

Copyright (c) 2026 Yurii Pavlenko

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files...

License: MIT

About

This is a tutorial project. JavaBasics_Task_46_V0.1 Implementing a cinema seat list display using a while loop with a step increment. 220126_1239

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages