English
Tasks
Complete the task of the chosen difficulty level for your variant number.
All basic solutions must compile without preview. Provide UML of the types and, for state models, a separate transition graph.
Variants
Variant 1. Arithmetic expressions
1. Initial level. Create a Java console program: enter the operation add or mul and two integers in −1000..1000; sealed Expr with records Num, Add, and Mul is evaluated by an exhaustive switch; print the result using Math.addExact and multiplyExact. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the operation add or mul and two integers in −1000..1000; sealed Expr with records Num, Add, and Mul is evaluated by an exhaustive switch; print the result using Math.addExact and multiplyExact. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the operation add or mul and two integers in −1000..1000; sealed Expr with records Num, Add, and Mul is evaluated by an exhaustive switch; print the result using Math.addExact and multiplyExact. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a tree in prefix format add 2 mul 3 4, with a depth up to 20, and simplification of addition of zero. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 2. A deck of cards
1. Initial level. Create a Java console program: enter the suit CLUBS, DIAMONDS, HEARTS, or SPADES and a rank in 2..14; use enum Suit and Rank with an explicit strength, and record Card; print the card and strength. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the suit CLUBS, DIAMONDS, HEARTS, or SPADES and a rank in 2..14; use enum Suit and Rank with an explicit strength, and record Card; print the card and strength. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the suit CLUBS, DIAMONDS, HEARTS, or SPADES and a rank in 2..14; use enum Suit and Rank with an explicit strength, and record Card; print the card and strength. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: all 52 cards without duplicates and comparison of two cards of the same suit. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 3. A traffic light
1. Initial level. Create a Java console program: enter the state RED, GREEN, or YELLOW and a step count of 0..20; enum Light transitions RED→GREEN→YELLOW→RED through switch; print the sequence. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the state RED, GREEN, or YELLOW and a step count of 0..20; enum Light transitions RED→GREEN→YELLOW→RED through switch; print the sequence. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the state RED, GREEN, or YELLOW and a step count of 0..20; enum Light transitions RED→GREEN→YELLOW→RED through switch; print the sequence. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a separate OFF mode as a sealed alternative without automatic transitions. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 4. Shapes as records
1. Initial level. Create a Java console program: enter the type circle or rectangle and positive finite dimensions up to 10000; sealed Shape and records Circle and Rectangle are evaluated using record patterns; print the area. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the type circle or rectangle and positive finite dimensions up to 10000; sealed Shape and records Circle and Rectangle are evaluated using record patterns; print the area. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the type circle or rectangle and positive finite dimensions up to 10000; sealed Shape and records Circle and Rectangle are evaluated using record patterns; print the area. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: perimeter and a when guard for an area less than one. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 5. Calendar events
1. Initial level. Create a Java console program: enter a title, an ISO date in 2020..2030, and start and end minutes in 0..1440, with start less than end; Event validates its components; print the duration. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter a title, an ISO date in 2020..2030, and start and end minutes in 0..1440, with start less than end; Event validates its components; print the duration. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter a title, an ISO date in 2020..2030, and start and end minutes in 0..1440, with start less than end; Event validates its components; print the duration. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: sealed SingleEvent and RepeatedEvent with a repetition count of 1..20 and a date table. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 6. Order statuses
1. Initial level. Create a Java console program: enter an identifier, the state NEW, PAID, SENT, DONE, or CANCELLED, and a target; allow NEW→PAID/CANCELLED, PAID→SENT/CANCELLED, and SENT→DONE; record Order returns a new state or a failure. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter an identifier, the state NEW, PAID, SENT, DONE, or CANCELLED, and a target; allow NEW→PAID/CANCELLED, PAID→SENT/CANCELLED, and SENT→DONE; record Order returns a new state or a failure. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter an identifier, the state NEW, PAID, SENT, DONE, or CANCELLED, and a target; allow NEW→PAID/CANCELLED, PAID→SENT/CANCELLED, and SENT→DONE; record Order returns a new state or a failure. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a history of up to 20 transitions and a count of completed orders. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 7. Payment methods
1. Initial level. Create a Java console program: enter the type card or cash and an amount of 1..1000000 kopiykas; sealed Payment with records CardPayment and CashPayment has a fee of 2 percent or 0; print the fictional amount without an actual transaction. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the type card or cash and an amount of 1..1000000 kopiykas; sealed Payment with records CardPayment and CashPayment has a fee of 2 percent or 0; print the fictional amount without an actual transaction. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the type card or cash and an amount of 1..1000000 kopiykas; sealed Payment with records CardPayment and CashPayment has a fee of 2 percent or 0; print the fictional amount without an actual transaction. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: record patterns and a third variant, Voucher, with a limit of 100000. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 8. A robot vacuum
1. Initial level. Create a Java console program: enter the state IDLE, CLEANING, or CHARGING and the command start, dock, or stop; the enum transitions IDLE→CLEANING on start, any state→CHARGING on dock, and CLEANING/CHARGING→IDLE on stop; print the state or failure. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the state IDLE, CLEANING, or CHARGING and the command start, dock, or stop; the enum transitions IDLE→CLEANING on start, any state→CHARGING on dock, and CLEANING/CHARGING→IDLE on stop; print the state or failure. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the state IDLE, CLEANING, or CHARGING and the command start, dock, or stop; the enum transitions IDLE→CLEANING on start, any state→CHARGING on dock, and CLEANING/CHARGING→IDLE on stop; print the state or failure. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: record Robot with a charge of 0..100 and a prohibition on start when charge is below 10. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 9. Measurement units
1. Initial level. Create a Java console program: enter a length of 0..1000000 and the unit M or CM; enum Unit has a conversion factor to meters, and record Length checks finiteness; print meters. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter a length of 0..1000000 and the unit M or CM; enum Unit has a conversion factor to meters, and record Length checks finiteness; print meters. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter a length of 0..1000000 and the unit M or CM; enum Unit has a conversion factor to meters, and record Length checks finiteness; print meters. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: normalized addition of two lengths and value comparison. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 10. A validation result
1. Initial level. Create a Java console program: enter an integer as a string; sealed ParseResult has records Success(int value) and Failure(String reason), and switch prints the doubled value as a long or the reason. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter an integer as a string; sealed ParseResult has records Success(int value) and Failure(String reason), and switch prints the doubled value as a long or the reason. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter an integer as a string; sealed ParseResult has records Success(int value) and Failure(String reason), and switch prints the doubled value as a long or the reason. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a Success pattern with when for negative values and a separate success total. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 11. Planets
1. Initial level. Create a Java console program: enter EARTH or MARS and a mass of 0..1000000 kg; enum Planet calculates weight using educational accelerations of 9.82 and 3.73; print the result. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter EARTH or MARS and a mass of 0..1000000 kg; enum Planet calculates weight using educational accelerations of 9.82 and 3.73; print the result. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter EARTH or MARS and a mass of 0..1000000 kg; enum Planet calculates weight using educational accelerations of 9.82 and 3.73; print the result. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: record Measurement with units and a comparison of weight on two planets. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 12. Chess moves
1. Initial level. Create a Java console program: enter the type rook or bishop and two squares with coordinates in 1..8; sealed Move uses records, and switch checks for a shared coordinate or equal absolute displacements; identical squares are prohibited; print validity without other pieces. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the type rook or bishop and two squares with coordinates in 1..8; sealed Move uses records, and switch checks for a shared coordinate or equal absolute displacements; identical squares are prohibited; print validity without other pieces. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the type rook or bishop and two squares with coordinates in 1..8; sealed Move uses records, and switch checks for a shared coordinate or equal absolute displacements; identical squares are prohibited; print validity without other pieces. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: record Square and nested patterns to extract coordinates. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 13. JSON values
1. Initial level. Create a Java console program: enter the type string, number, or null and the corresponding value: a string of up to 100 characters or a finite number; sealed JsonValue uses records to print JSON with correctly escaped quotation marks, backslashes, and newlines. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the type string, number, or null and the corresponding value: a string of up to 100 characters or a finite number; sealed JsonValue uses records to print JSON with correctly escaped quotation marks, backslashes, and newlines. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the type string, number, or null and the corresponding value: a string of up to 100 characters or a finite number; sealed JsonValue uses records to print JSON with correctly escaped quotation marks, backslashes, and newlines. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: an array of up to 20 values and recursive formatting with a depth up to 10. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 14. Work shifts
1. Initial level. Create a Java console program: enter the type DAY or NIGHT and hours in 1..12; enum Shift defines an educational rate of 10000 or 15000 kopiykas, and record Work calculates the total; print the pay. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the type DAY or NIGHT and hours in 1..12; enum Shift defines an educational rate of 10000 or 15000 kopiykas, and record Work calculates the total; print the pay. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the type DAY or NIGHT and hours in 1..12; enum Shift defines an educational rate of 10000 or 15000 kopiykas, and record Work calculates the total; print the pay. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: totals by shift type and record equality checks. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 15. A messenger
1. Initial level. Create a Java console program: enter the type text or image; text has up to 200 characters, and an image has a name and dimensions in 1..10000; sealed Message with records produces a preview through patterns; print the text or dimensions. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the type text or image; text has up to 200 characters, and an image has a name and dimensions in 1..10000; sealed Message with records produces a preview through patterns; print the text or dimensions. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the type text or image; text has up to 200 characters, and an image has a name and dimensions in 1..10000; sealed Message with records produces a preview through patterns; print the text or dimensions. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: AudioMessage with a duration of 1..7200 seconds and an update to the exhaustive switch. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 16. Banking operations
1. Initial level. Create a Java console program: enter the type deposit or withdraw, an amount of 1..1000000, and an initial balance of 0..1000000 kopiykas; sealed Operation and switch apply the action without a negative balance or exceeding the limit; print the new balance. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the type deposit or withdraw, an amount of 1..1000000, and an initial balance of 0..1000000 kopiykas; sealed Operation and switch apply the action without a negative balance or exceeding the balance limit of 1000000 kopiykas; print the new balance. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the type deposit or withdraw, an amount of 1..1000000, and an initial balance of 0..1000000 kopiykas; sealed Operation and switch apply the action without a negative balance or exceeding the limit; print the new balance. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a sequence of immutable record snapshots after each successful operation. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 17. Tickets
1. Initial level. Create a Java console program: enter the type standard or child and a base price of 1..100000; sealed Ticket with records applies a zero or 50-percent discount; print the amount in kopiykas. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the type standard or child and a base price of 1..100000; sealed Ticket with records applies a zero or 50-percent discount; print the amount in kopiykas. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the type standard or child and a base price of 1..100000; sealed Ticket with records applies a zero or 50-percent discount; print the amount in kopiykas. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: enum Zone with factors of 1, 2, and 3 and a nested record pattern. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 18. Geographic routes
1. Initial level. Create a Java console program: enter two Cartesian points x,y in −1000..1000; records Point and Route return Math.hypot of the differences, using arbitrary units; print the length. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter two Cartesian points x,y in −1000..1000; records Point and Route return Math.hypot of the differences, using arbitrary units; print the length. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter two Cartesian points x,y in −1000..1000; records Point and Route return Math.hypot of the differences, using arbitrary units; print the length. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: sealed Route with a direct route and a two-segment route through an intermediate point. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 19. ATM states
1. Initial level. Create a Java console program: enter the state IDLE, CARD, or AUTHORIZED and the command insert, authenticate, or eject; allow IDLE→CARD, CARD→AUTHORIZED, and CARD/AUTHORIZED→IDLE respectively; print the state without actual cards or PINs. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the state IDLE, CARD, or AUTHORIZED and the command insert, authenticate, or eject; allow IDLE→CARD, CARD→AUTHORIZED, and CARD/AUTHORIZED→IDLE respectively; print the state without actual cards or PINs. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the state IDLE, CARD, or AUTHORIZED and the command insert, authenticate, or eject; allow IDLE→CARD, CARD→AUTHORIZED, and CARD/AUTHORIZED→IDLE respectively; print the state without actual cards or PINs. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a sealed Accepted/Rejected result with an explanation and a command log. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 20. ECTS grades
1. Initial level. Create a Java console program: enter a score of 0..100; define enum Grade using the educational thresholds A90, B82, C74, D64, E60, FX35, F0; record Result prints the letter and score. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter a score of 0..100; define enum Grade using the educational thresholds A90, B82, C74, D64, E60, FX35, F0; record Result prints the letter and score. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter a score of 0..100; define enum Grade using the educational thresholds A90, B82, C74, D64, E60, FX35, F0; record Result prints the letter and score. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a compact constructor, name normalization, and totals by category. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 21. Game inventory
1. Initial level. Create a Java console program: enter the type weapon or potion, a name, and a value of 1..100; sealed Item with records describes damage or healing; print the description through switch. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the type weapon or potion, a name, and a value of 1..100; sealed Item with records describes damage or healing; print the description through switch. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the type weapon or potion, a name, and a value of 1..100; sealed Item with records describes damage or healing; print the description through switch. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: enum Rarity and a guarded branch for a value above 80. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 22. Weather measurements
1. Initial level. Create a Java console program: enter a city, a temperature in −50..60, and the condition CLEAR, CLOUDY, or RAIN; record Weather and enum Condition produce a description; print the temperature and condition. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter a city, a temperature in −50..60, and the condition CLEAR, CLOUDY, or RAIN; record Weather and enum Condition produce a description; print the temperature and condition. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter a city, a temperature in −50..60, and the condition CLEAR, CLOUDY, or RAIN; record Weather and enum Condition produce a description; print the temperature and condition. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: sealed Reading with Valid and Missing and totals of missing measurements. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 23. Prescription records
1. Initial level. Create a Java console program: enter an educational prescription code, a medication name, and the status CREATED, ISSUED, or CLOSED; record Prescription validates nonempty fields, and the enum defines CREATED→ISSUED→CLOSED; print the state without dosage recommendations. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter an educational prescription code, a medication name, and the status CREATED, ISSUED, or CLOSED; record Prescription validates nonempty fields, and the enum defines CREATED→ISSUED→CLOSED; print the state without dosage recommendations. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter an educational prescription code, a medication name, and the status CREATED, ISSUED, or CLOSED; record Prescription validates nonempty fields, and the enum defines CREATED→ISSUED→CLOSED; print the state without dosage recommendations. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a sealed transition result and rejection after CLOSED. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 24. Road signs
1. Initial level. Create a Java console program: enter the type speed or stop; SpeedLimit has a number in 10..130, while Stop has no components; sealed Sign uses switch to produce an educational description; print the result. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the type speed or stop; SpeedLimit has a number in 10..130, while Stop has no components; sealed Sign uses switch to produce an educational description; print the result. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the type speed or stop; SpeedLimit has a number in 10..130, while Stop has no components; sealed Sign uses switch to produce an educational description; print the result. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: enum Category and when for a speed no greater than 30. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 25. RGB and HSL colors
1. Initial level. Create a Java console program: enter R,G,B in 0..255; record Rgb validates the components; print the hexadecimal code; enum Channel defines component selection. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter R,G,B in 0..255; record Rgb validates the components; print the hexadecimal code; enum Channel defines component selection. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter R,G,B in 0..255; record Rgb validates the components; print the hexadecimal code; enum Channel defines component selection. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: sealed Color with Rgb and Hsl, H in 0..359, S/L in 0..100, and text formatting without mandatory conversion. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 26. Gym memberships
1. Initial level. Create a Java console program: enter the type DAY or MONTH and a unit count of 1..12; enum Plan defines a fictional price of 15000 or 120000 kopiykas, and record Membership calculates the total; print the total. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the type DAY or MONTH and a unit count of 1..12; enum Plan defines a fictional price of 15000 or 120000 kopiykas, and record Membership calculates the total; print the total. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the type DAY or MONTH and a unit count of 1..12; enum Plan defines a fictional price of 15000 or 120000 kopiykas, and record Membership calculates the total; print the total. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a sealed Active/Expired state with an ISO date and transition validation. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 27. Console commands
1. Initial level. Create a Java console program: enter a line containing add with two integer arguments or echo with text; sealed Command with records is parsed and executed by switch; print a long sum or the text. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter a line containing add with two integer arguments or echo with text; sealed Command with records is parsed and executed by switch; print a long sum or the text. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter a line containing add with two integer arguments or echo with text; sealed Command with records is parsed and executed by switch; print a long sum or the text. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: Help as a separate command and Error as a validated parsing result. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 28. Insurance claims
1. Initial level. Create a Java console program: enter the type minor or major and a loss of 0..10000000 kopiykas; sealed Claim with records returns educational compensation of 50 or 80 percent; print the amount without treating it as actual insurance terms. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the type minor or major and a loss of 0..10000000 kopiykas; sealed Claim with records returns educational compensation of 50 or 80 percent; print the amount without treating it as actual insurance terms. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the type minor or major and a loss of 0..10000000 kopiykas; sealed Claim with records returns educational compensation of 50 or 80 percent; print the amount without treating it as actual insurance terms. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: enum ReviewStatus and transitions NEW→APPROVED/REJECTED. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 29. Mail shipments
1. Initial level. Create a Java console program: enter the type letter or parcel, a code, and a weight of 1..10000 g; sealed Shipment returns a fictional price of 2000 or 5000 plus the weight in kopiykas; print the description and price. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the type letter or parcel, a code, and a weight of 1..10000 g; sealed Shipment returns a fictional price of 2000 or 5000 plus the weight in kopiykas; print the description and price. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the type letter or parcel, a code, and a weight of 1..10000 g; sealed Shipment returns a fictional price of 2000 or 5000 plus the weight in kopiykas; print the description and price. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: record Address with a nonempty city and a nested delivery pattern. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 30. Coffee orders
1. Initial level. Create a Java console program: enter the type ESPRESSO or LATTE and the size SMALL or LARGE; enum Coffee defines 3000/4500, and Size defines a multiplier of 1/2; record CoffeeOrder prints the price in kopiykas. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview.
2. Basic level. Create a Java console program: enter the type ESPRESSO or LATTE and the size SMALL or LARGE; enum Coffee defines 3000/4500, and Size defines a multiplier of 1/2; record CoffeeOrder prints the price in kopiykas. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the type ESPRESSO or LATTE and the size SMALL or LARGE; enum Coffee defines 3000/4500, and Size defines a multiplier of 1/2; record CoffeeOrder prints the price in kopiykas. Provide a class UML diagram; use validated records, an enum, or a sealed hierarchy as appropriate for the model; use stable JDK 27 syntax without preview. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: sealed AddOn with None and Milk(ml), where 1..200 ml adds 10 kopiykas per ml. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Procedure
- Define the value components and valid alternatives.
- Provide UML with record, enum, and sealed notation.
- Implement compact constructors and normalization.
- Ensure defensive copying of mutable components.
- Implement an exhaustive switch and an explicit null policy.
- Test boundaries, equality, failures, and every state.
- Provide code, a README, and at least five checks.
- During the presentation, add an alternative and explain the diagnostic.