English
Tasks
Complete the task of the chosen difficulty level for your variant number.
If the rates are classroom ones, don’t replace them with current legal rates.
Variants
Variant 1. Income tax
1. Initial level. Create a console program: read an income of 0–1000000 from the keyboard and calculate a sample tax of 10%. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read an income from the keyboard and apply a sample scale: the first 10000 at 10%, the rest at 20%; print the tax and the net income. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read a start, an end, and a positive step of incomes up to 1000000 from the keyboard; print a table of the tax on the scale of 10% up to 10000 and 20% above it, and the effective rate. Validate the input ranges; report errors to the user.
Variant 2. Leap year
1. Initial level. Create a console program: read a year 1–9999 from the keyboard and report whether it is a leap year according to the Gregorian calendar rule. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read a year and a month from the keyboard and print the number of days, validating the numbers. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read a year, a month, and the day of the week of the first day of the month (1–7) from the keyboard; print a calendar with the correct number of days and alignment. Validate the input ranges; report errors to the user.
Variant 3. Quadratic equation
1. Initial level. Create a console program: read a, b, c with a nonzero a from the keyboard and print the real roots or report that there are none. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read a, b, c from the keyboard; also handle the linear, inconsistent, and identity cases; print the type of the solution. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read a count of up to 100 and a series of triples a, b, c from the keyboard; print a table of discriminants and numbers of roots; reject infinite data. Validate the input ranges; report errors to the user.
Variant 4. Digits of a number
1. Initial level. Create a console program: read a nonnegative number up to 1000000000 from the keyboard and print the sum of its digits. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read a number up to 1000000000 from the keyboard; print its reverse and whether it is a palindrome, handling 0 separately. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read limits 0–999999 from the keyboard; print six-digit lucky numbers with leading zeros, the sums of the first and last three digits, and the count. Validate the input ranges; report errors to the user.
Variant 5. Prime numbers
1. Initial level. Create a console program: read n in the range 2–1000000 from the keyboard and check whether it is prime by trial division up to n/d. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read limits 2–100000 from the keyboard and print the prime numbers five per line. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read limits 2–100000 from the keyboard; print the prime numbers, the largest gap between neighbors, and the count, including an empty result. Validate the input ranges; report errors to the user.
Variant 6. Parking
1. Initial level. Create a console program: read hours 1–24 from the keyboard; print the fee at a sample rate of 20 per hour. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read minutes 1–1440 and a day of the week 1–7 from the keyboard; round the hours up, apply 20 on weekdays and 15 on weekends, and print a receipt. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read up to 100 parking sessions with minutes and a day of the week from the keyboard; the rate is 20/15 per started hour, with a maximum of 200 per day; print the receipts and the total revenue. Validate the input ranges; report errors to the user.
Variant 7. Electricity
1. Initial level. Create a console program: read a consumption of 0–10000 and a sample rate from the keyboard and print the cost. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read day and night kWh and rates of 4 and 2 from the keyboard; print the two-zone total and the savings compared with a single rate of 4. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read 12 monthly consumption pairs from the keyboard; print a table of charges at the 4/2 rates, the annual savings compared with 4, and the month with the largest savings. Validate the input ranges; report errors to the user.
Variant 8. Deposit
1. Initial level. Create a console program: read an amount of 1–1000000 and an annual interest rate of 0–100 from the keyboard; print the amount after one year. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read an amount, an interest rate, and a number of months 1–120 from the keyboard; print monthly compounding without additional deposits. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read an amount, an annual interest rate, a monthly deposit, and months 1–120 from the keyboard; each month, add the interest first and then the deposit; print the contributions and the accrued interest separately. Validate the input ranges; report errors to the user.
Variant 9. Fuel consumption
1. Initial level. Create a console program: read a distance and liters per 100 km from the keyboard; print the fuel needed. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read a distance, a consumption rate, and the price per liter from the keyboard; check that they are positive and print the liters and the cost. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read up to 100 trips with a distance, liters, and a price from the keyboard; print the total cost and the weighted consumption per 100 km, and don’t divide by a zero distance. Validate the input ranges; report errors to the user.
Variant 10. Length converter
1. Initial level. Create a console program: read meters 0–1000000 from the keyboard; print centimeters and kilometers. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read a unit code m, cm, km and a nonnegative value from the keyboard; print meters, and reject an unknown code. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program with a numeric menu for m/cm/km conversion and a table for entered limits and a positive step; print at most 1000 rows. Validate the input ranges; report errors to the user.
Variant 11. Grading scale
1. Initial level. Create a console program: read a score 0–100 from the keyboard; print A for 90+, B for 82+, C for 74+, D for 64+, E for 60+, F below 60. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read a count 1–100 and the scores from the keyboard; print the letters A/B/C/D/E/F using the cutoffs 90/82/74/64/60, and the average score. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read scores from the keyboard until the sentinel -1; print the counts of the categories using the cutoffs 90/82/74/64/60, the average, and the share of passing scores; handle an empty set separately. Validate the input ranges; report errors to the user.
Variant 12. Binary representation
1. Initial level. Create a console program: read an unsigned 0–255 from the keyboard; print 8 bits and the hexadecimal notation. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read a number 0–255 and a bit number 0–7 from the keyboard; print the value of the bit and the number after that bit is inverted. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read two numbers 0–255 from the keyboard; print a table of AND, OR, XOR, and shifts by 0–7 in binary and decimal formats. Validate the input ranges; report errors to the user.
Variant 13. Collatz sequence
1. Initial level. Create a console program: read n in the range 1–100000 from the keyboard; print the sequence down to 1 with a limit of 1000 steps. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read n in the range 1–1000000 from the keyboard; print the length and the maximum, checking whether 3*n+1 can be computed. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read limits 1–10000 from the keyboard; find the starting value with the longest sequence, choosing the smaller one in a tie; guard against overflow and a limit of 10000 steps. Validate the input ranges; report errors to the user.
Variant 14. Perfect numbers
1. Initial level. Create a console program: read n in the range 1–100000 from the keyboard; print the sum of its proper divisors and whether it is perfect. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read N in the range 2–10000 from the keyboard; print all perfect numbers up to N and their divisors. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read N in the range 2–5000 from the keyboard; find amicable pairs a<b<=N using the sums of proper divisors, without duplicates. Validate the input ranges; report errors to the user.
Variant 15. Loan
1. Initial level. Create a console program: read an amount and months 1–120 from the keyboard; for a zero interest rate, print an equal monthly payment. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read an amount, an annual rate 0–100, and months 1–120 from the keyboard; calculate the annuity payment, handling the rate 0 separately. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read an amount, a rate, and months from the keyboard; print a schedule of the remaining balance, interest, and principal repayment, adjust the last payment, and compare the total overpayment. Validate the input ranges; report errors to the user.
Variant 16. Delivery
1. Initial level. Create a console program: read a finite weight weight in the range 0–30 kg from the keyboard; calculate the sample price base = 50 + 10 * ceil(weight). Print the weight, the number of started kilograms, and the price in UAH with two decimal places; for a zero weight, the price is 50 UAH. Validate the input; explain invalid data with a message.
2. Basic level. Create a console program: read a weight weight in the range 0–30 kg, an integer zone zone in the range 1–3, and urgency urgent as 0 or 1 from the keyboard; calculate base = 50 + 10 * ceil(weight) and total = base * zone * (urgent == 1 ? 1.5 : 1.0). Print the number of started kilograms, the base price, both multipliers, and the final price in UAH with two decimal places. For a zero weight, the base price is 50 UAH. Reject an infinite weight and NaN. Validate the input; explain invalid data with a message.
3. Advanced level. Create a console program with a menu for adding a parcel, printing a report, and exiting; store up to 100 parcels. For each addition, read a weight weight in the range 0–30 kg, an integer zone zone in the range 1–3, and urgency urgent as 0 or 1 from the keyboard; calculate base = 50 + 10 * ceil(weight) and total = base * zone * (urgent == 1 ? 1.5 : 1.0). Print the number of started kilograms, the base price, both multipliers, and the final price in UAH with two decimal places. For a zero weight, the base price is 50 UAH. The report must contain the receipts of all parcels, the count and the total for each zone, and the grand total; for an empty list, all totals are zero. Reject an infinite weight, NaN, and additions beyond the limit. Validate the input; explain invalid data with a message.
Variant 17. Knight’s move
1. Initial level. Create a console program: read two squares as a row and a column 1–8 from the keyboard; check whether it is a knight’s move. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read a square 1–8, 1–8 from the keyboard; print an 8×8 board marking all valid moves. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read a sequence of up to 100 squares from the keyboard; check each knight move, and print the number of the first invalid one and the total of valid moves. Validate the input ranges; report errors to the user.
Variant 18. Temperatures
1. Initial level. Create a console program: read a Celsius value not lower than -273.15 from the keyboard; print Fahrenheit and Kelvin. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read a start, an end, and a positive step in Celsius from the keyboard; print at most 1000 rows of C/F/K. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program that implements a C/F/K menu, checks absolute zero in the selected scale, and builds a conversion table with a given step. Validate the input ranges; report errors to the user.
Variant 19. Running pace
1. Initial level. Create a console program: read positive kilometers and minutes from the keyboard; print km/h. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read a distance and seconds from the keyboard; print the pace in min:s per kilometer with rounding. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read up to 100 segments with kilometers and seconds from the keyboard; print the overall pace and a linear prediction for 42.195 km, and explain the constant-pace model. Validate the input ranges; report errors to the user.
Variant 20. GCD
1. Initial level. Create a console program: read two positive numbers up to 1000000 from the keyboard; print the GCD using the Euclidean algorithm. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read a numerator 0–1000000 and a denominator 1–1000000 from the keyboard; print the reduced fraction. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read a series of up to 100 fractions from the keyboard; print the reduced form of each and the number of Euclidean steps, and handle a zero numerator. Validate the input ranges; report errors to the user.
Variant 21. Fibonacci
1. Initial level. Create a console program: read N in the range 1–40 from the keyboard; print the first N numbers starting with 0, 1. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read N in the range 1–100 from the keyboard; print the terms up to the first addition that doesn’t fit in long long, and report its index. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read a limit from 0 to the maximum of long long from the keyboard; print all Fibonacci numbers not greater than the limit and their indices, without performing an overflowing addition. Validate the input ranges; report errors to the user.
Variant 22. Dice
1. Initial level. Create a console program: read an engine seed from the keyboard and print two dice 1–6 and their sum. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read a seed and a count 1–100000 from the keyboard; print the frequency of the sum 7 with two dice. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read a seed and a number of rolls 1–1000000 from the keyboard; print the frequencies of all sums 2–12 and the percentages, and check the sum of the frequencies. Validate the input ranges; report errors to the user.
Variant 23. Discounts
1. Initial level. Create a console program: read an amount from the keyboard; apply 5% from 1000 and 0% below it, and print the amount to pay. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read an amount from the keyboard; apply 0% below 1000, 5% from 1000, and 10% from 5000, and print the discount and the amount to pay. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read up to 100 items with a price and a quantity from the keyboard; print a receipt, a discount of 0/5/10% at the thresholds 1000/5000, and the total. Validate the input ranges; report errors to the user.
Variant 24. Salary
1. Initial level. Create a console program: read hours 0–168 and an hourly rate from the keyboard; print the pay without extras. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read hours and an hourly rate from the keyboard; the first 40 hours are regular, the rest have a factor of 1.5; print the components. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read 7 daily hour values 0–24 and an hourly rate from the keyboard; print a timesheet, the weekly pay with 1.5 over 40 hours, and a sample 10% deduction. Validate the input ranges; report errors to the user.
Variant 25. Time of day
1. Initial level. Create a console program: read minutes 0–1439 from the keyboard; print hh:mm. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read hours 0–23 and minutes 0–59 from the keyboard; print the 12-hour format with AM/PM. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read two moments hh mm from the keyboard; print the duration until the second one, crossing midnight if needed, and treat equal moments as 0. Validate the input ranges; report errors to the user.
Variant 26. Taylor series
1. Initial level. Create a console program: read x in the range -1..1 from the keyboard; calculate x-x³/6+x⁵/120 and compare it with std::sin. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read x in the range -3..3 and a precision of 1e-12..1e-3 from the keyboard; add the terms of sin recursively until the tolerance is reached, with a limit of 100. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read limits of x in the range -3..3, a step, and a precision from the keyboard; print a table of approximations, numbers of terms, and errors compared with std::sin for at most 1000 points. Validate the input ranges; report errors to the user.
Variant 27. Integration
1. Initial level. Create a console program: read a<b and N in the range 1–100000 from the keyboard; calculate the integral of x² with left rectangles. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read a<b, N from the keyboard; compare left and midpoint rectangles for x² with the exact value (b³-a³)/3. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read a<b and a tolerance from the keyboard; double N for midpoint rectangles of x² until the change is below the tolerance or N=1048576; print a convergence table. Validate the input ranges; report errors to the user.
Variant 28. Traffic light
1. Initial level. Create a console program: read a state 0–2 from the keyboard; using enum class, print the name red, yellow, green. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read a number of cycles 1–100 from the keyboard; print the sequence red 30, green 25, yellow 5 and the accumulated time. Validate the input ranges; report errors to the user.
3. Advanced level. Create a traffic light console program: read the durations of the red, green, and yellow signals 1–120 s and a time of 0–100000 s from the keyboard; simulate the signal changes, and print the active signal at the end and the number of completed cycles. Validate the input ranges; report errors to the user.
Variant 29. Battery
1. Initial level. Create a console program: read a capacity and a current from the keyboard; calculate the ideal charging time without losses. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read a capacity, an initial percentage 0–100, and a positive current from the keyboard; print the ideal time to 100%. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read a capacity, an initial charge, and a current from the keyboard; print a minute-by-minute table of the linear model up to 100% with a limit of 1440 min, without exceeding 100%. Validate the input ranges; report errors to the user.
Variant 30. Taxi
1. Initial level. Create a console program: read kilometers 0–1000 from the keyboard; print the sample fare 60+15*km. Validate the input ranges; report errors to the user.
2. Basic level. Create a console program: read kilometers and a night flag 0/1 from the keyboard; at night, multiply the base fare (60 + 15 * km) by 1.2; print a receipt. Validate the input ranges; report errors to the user.
3. Advanced level. Create a console program: read up to 100 rides with a distance, waiting minutes, and a night flag from the keyboard; the fare is (60+15*km+3*min)*1.2 at night; print the receipts and the total. Validate the input ranges; report errors to the user.
Procedure
- Write down the input data, units, constraints, and the expected result.
- Choose types and check whether intermediate values fit.
- Implement validation of the stream, the ranges, and the end of input.
- Build the program with
/W4; fix meaningful warnings. - Test ordinary, boundary, and invalid data; record the results.
- Explain the order of execution of one branch and one loop.
- Create a commit with the code and a short test table in the README.