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

16th Mar 2019, 11:37 AM
Bruder Muss los
Bruder Muss los - avatar
3 Respostas
+ 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.
16th Mar 2019, 12:43 PM
Hatsy Rei
Hatsy Rei - avatar
+ 2
16th Mar 2019, 1:07 PM
Daljeet Singh
Daljeet Singh - avatar
0
thx mate
16th Mar 2019, 5:54 PM
Bruder Muss los
Bruder Muss los - avatar