CJCoding With Joseph
15free / daySign inCreate account
TitleTopicsAction
145
Throw on Division by ZeroComplete the `safeDivide` function below. If `b` is 0, throw a `std::runtime_er...
easy○ Not Started
FunctionsExceptions
Solve
146
Catch a Runtime ErrorThe function `riskyDivide` below already throws a `std::runtime_error` when `b` ...
easy○ Not Started
FunctionsExceptions
Solve
147
Validate Age with ExceptionComplete the `validateAge(int age)` function. - If `age` is less than 0, throw ...
easy○ Not Started
FunctionsExceptions
Solve
148
Safe List AccessCreate a class `SafeList` that wraps a `vector<int>` and prevents out-of-bounds ...
easy○ Not Started
ClassesExceptions
Solve
149
Throw in ConstructorCreate a class `Rectangle` with private `double width` and `double height`. Req...
easy○ Not Started
ClassesExceptions
Solve
150
Validate Test ScoreComplete the `validateScore(int score)` function. - If `score` is less than 0 o...
easy○ Not Started
FunctionsExceptions
Solve
760
Parking Fee Refuses Negative HoursWrite a function `parkingFee(int hours)` that returns the cost of parking as a `...
easy○ Not Started
Exceptions
Solve
761
Ticket Order With Two Kinds of ErrorWrite a function `ticketTotal(int count)` that returns the price of `count` tick...
easy○ Not Started
Exceptions
Solve
762
Report Overdue Days or the ProblemThe function `daysOverdue(int dueDay, int returnDay)` is already written: it ret...
easy○ Not Started
Exceptions
Solve
763
Keep Going After a Skipped GuestThe function `greeting(const std::string& name)` is already written: it returns ...
easy○ Not Started
Exceptions
Solve
764
Price Every Item and Skip the Unknown OnesThe function `priceOf(const std::string& item)` is already written: it returns t...
easy○ Not Started
Exceptions
Solve
765
Three Handlers for a Cash MachineThe function `withdrawCash(int amount)` is already written. It throws a `std::in...
easy○ Not Started
Exceptions
Solve
766
Look Up a Seat Safely with at()A `std::vector` has two ways to read an element: `seats[index]` does no checking...
easy○ Not Started
Exceptions
Solve
151
Multiple Catch BlocksWrite two functions that demonstrate catching different exception types: 1. `pr...
medium○ Not Started
FunctionsExceptions
Solve
152
BankAccount Withdraw ExceptionCreate a class `BankAccount` with a private `double balance`. Requirements: 1. ...
medium○ Not Started
ClassesExceptions
Solve
153
Custom Exception ClassCreate a custom exception class `ValidationError` that inherits from `std::excep...
medium○ Not Started
ClassesExceptions
Solve
154
Rethrowing ExceptionsWrite two functions that demonstrate logging and rethrowing an exception: 1. `l...
medium○ Not Started
FunctionsExceptions
Solve
767
Log It, Then RethrowThe function `loadLevel(int number)` is already written: it returns the points f...
medium○ Not Started
Exceptions
Solve
768
Nested Try for a Score LookupThe function `scoreAt(const std::vector<int>& scores, int index)` is already wri...
medium○ Not Started
Exceptions
Solve
769
Parse a Quantity with Clear Messages`std::stoi` turns text into an `int`, but it reports problems with two library e...
medium○ Not Started
Exceptions
Solve
770
A Thermostat That Refuses Bad SettingsComplete the class `Thermostat`. Its constructor `Thermostat(int celsius)` check...
medium○ Not Started
Exceptions
Solve
771
Empty Name Error ClassCreate your own exception type `EmptyNameError` that inherits publicly from `std...
medium○ Not Started
Exceptions
Solve
772
Unknown Item Error with a Built MessageCreate an exception type `UnknownItemError` that inherits publicly from `std::ru...
medium○ Not Started
Exceptions
Solve
773
Bad Quantity Error Carries the ValueAn exception can carry data about what went wrong. Complete `BadQuantityError`, ...
medium○ Not Started
Exceptions
Solve
774
Parse an Age Without ThrowingNot every error needs an exception. Write `tryParseAge(const std::string& text, ...
medium○ Not Started
Exceptions
Solve
775
Custom Error Hierarchy for App SettingsBuild a small family of exception classes and a function that throws them: - `A...
medium○ Not Started
Exceptions
Solve
776
Device Error with a Code and a MessageAn exception can carry more than a sentence. Build `DeviceError`, which inherits...
medium○ Not Started
Exceptions
Solve
777
Inventory That Reports the ShortfallMost of `Inventory` is written: it tracks one item and how many are on the shelf...
medium○ Not Started
Exceptions
Solve
778
Guard Destructor Runs Before the CatchWhen an exception leaves a function, every local object in that function is dest...
medium○ Not Started
Exceptions
Solve
779
Factory That Falls Back on a Bad TemperatureA constructor has no return value to report a problem with, so it throws. A fact...
medium○ Not Started
Exceptions
Solve
780
Translate a Low-Level Error into a Sensor ErrorThe provided `readRaw(int slot)` throws a `std::out_of_range` for a slot that do...
medium○ Not Started
Exceptions
Solve
781
Retry a Flaky Send Three TimesThe provided `send(int attempt, int failures)` throws a `std::runtime_error("tim...
medium○ Not Started
Exceptions
Solve
782
Catch and Report Any TaskWrite `void catchAndReport(void (*task)(), const std::string& label)`, a safety ...
medium○ Not Started
Exceptions
Solve
783
Validate a Record with Three Error TypesBuild four exception classes and one validator from scratch: - `RecordError` in...
hard○ Not Started
Exceptions
Solve
784
Bounded Stack with Overflow and UnderflowBuild a class `BoundedStack` from scratch. It holds at most three `int` values i...
hard○ Not Started
Exceptions
Solve
785
Wrap Legacy Error Codes in a File ErrorOld code reports problems with numbers: the provided `legacyOpen(path)` returns ...
hard○ Not Started
Exceptions
Solve
786
A Purchase That Changes Nothing When It FailsA `Wallet` holds coins and gems, and a purchase costs some of each. The rule is ...
hard○ Not Started
Exceptions
Solve
787
A what() Built from a Stored String`std::exception` itself stores no message, so a class that inherits from it dire...
hard○ Not Started
Exceptions
Solve
788
One Catch for a Whole Family of Shop ErrorsBecause `what()` is virtual, a single `catch (const std::exception&)` can report...
hard○ Not Started
Exceptions
Solve
789
Account with Three Custom ExceptionsBuild a small bank account and the three exceptions it throws, from scratch: - ...
hard○ Not Started
Exceptions
Solve