This exercise focuses on creating and testing Java methods. Each task introduces key programming concepts, including test methods, arithmetic calculations, text conversion, and method overloading.
Develop test methods for array operations:
testMax
: Tests themax
method, which finds the maximum value in an array.testAdd
: Tests theadd
method, which adds a given value to each element of an array.
Implement methods to calculate:
- Cost Price: Includes material and manufacturing costs plus a 20% distribution markup.
- Sales Price: Adds a 30% profit margin to the cost price.
Convert numbers to their text representation:
digitToText
: Maps digits (0–9) to their English names (e.g.,7 → "Seven"
).numberToText
: Converts whole numbers to concatenated digit names (e.g.,123 → "OneTwoThree"
).
Round values to the closest of two boundary values:
roundToClosest(int min, int max, int value)
: Rounds a single value.roundToClosest(int min, int max, int... values)
: Rounds multiple values using the first method.
src/
In.java
Helper class for inputOut.java
Helper class for outputArrayMethods.java
Contains methods for array operations and their testsProductPricing.java
Implements cost and sales price calculationsNumbersToText.java
Implements digit-to-text and number-to-text conversionsRoundToClosest.java
Implements rounding methods
tests/
Testprotokolle.txt
Test cases and results for all tasks
- Test Coverage: Each task includes tests for typical cases and edge cases (e.g., negative inputs).
- Floating-Point Precision: Comparisons account for imprecision using tolerances.
- Modular Design: Methods are reused where possible to reduce duplication.
- Programming Language: Java
- Editor: Visual Studio Code with JavaWiz extension
This project is licensed under the MIT License.