This project demonstrates the use of integer division and the modulo operator (%) in Java. It simulates a scenario where a set number of prizes must be distributed equally among teams, and the remainder is calculated.
- Create two
intvariables:prizes(15) andteams(4). - Calculate and display:
- How many whole prizes each team receives (integer division).
- How many prizes remain after distribution (remainder).
After running the program, the console should display:
Number of prizes for each team: 3
Remaining prizes: 3
- Language: Java 23
- IDE: IntelliJ IDEA
- Concepts: Integer division (/), Modulo operator (%), Console output.
The code follows Java naming conventions and clean code principles.
The code calculates the distribution using integer division and the modulo operator, providing clear and informative console output:
package com.yurii.pavlenko;
public class Task_10_App {
public static void main(String[] args) {
int prizes = 15;
int teams = 4;
int prizesForTeam = prizes / teams;
int remainingPrizes = prizes % teams;
System.out.println("Number of prizes for each team: " + prizesForTeam);
System.out.println("Remaining prizes: " + remainingPrizes);
}
}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