0
Help with exception pls
Hey, I’ve wrote a code to calculate your marks. So far everything works, but I wanted to include an exception to output an error code when you enter a mark that’s not in the range of 0-15 (marks in Germany) can somebody pls tell me what I did wrong? https://code.sololearn.com/c4GhicRpbAfr/?ref=app
3 Antworten
+ 4
catch (int 1)
is a syntax error. You are supposed to catch what you've thrown as a variable. That said, judging from what you're trying to do,
catch (...)
will suffice. Also, where is your 'try' statement? Your code is supposed to look like this:
try {
// all your code here
}
catch (...) {
// handle caught exceptions
}
As it is right now, it looks like you have no try block, and the catch block is somewhere in the middle of the code. Your "eres" variable is declared in a for loop... There are a lot of things you need to fix.
+ 2
Bruder Muss los why did you remove your last question?
https://code.sololearn.com/c2rvRBPs1p8J/?ref=app
0
thx mate