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 themaxmethod, which finds the maximum value in an array.testAdd: Tests theaddmethod, 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.javaHelper class for inputOut.javaHelper class for outputArrayMethods.javaContains methods for array operations and their testsProductPricing.javaImplements cost and sales price calculationsNumbersToText.javaImplements digit-to-text and number-to-text conversionsRoundToClosest.javaImplements rounding methods
tests/
Testprotokolle.txtTest 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.