+ 2

[OFF-TOPIC] I think mean I'm here

I can do my best https://code.sololearn.com/crHVVwaCwkc3/?ref=app

6th Apr 2018, 10:28 PM
‎Omer S. Hassan
‎Omer S. Hassan - avatar
3 Answers
+ 3
Try to make indents in code with correct length. YOUR CODE: if ( myArr[x]>=0 && myArr[x]<=100){ sum+= myArr[x]; //The sumation of degree if (myArr[x]>=50){ System.out.println("Lesson"+ x+" = "+ myArr[x]+" Pass");} //If there is a degree larg than 50% else { System.out.println("Lesson"+ x+" = "+ myArr[x]+" Fail"); } } else { System.out.println("ERROR"); } } SHOULD BE: if (myArr[x]>=0 && myArr[x]<=100) { sum+= myArr[x]; //The sumation of degree if (myArr[x]>=50) System.out.println("Lesson"+ x+" = "+ myArr[x]+" Pass"); else System.out.println("Lesson"+ x+" = "+ myArr[x]+" Fail"); } else System.out.println("ERROR");
6th Apr 2018, 11:04 PM
Bartosz Pieszko
Bartosz Pieszko - avatar
+ 1
I've tweaked it a bit: 1) Better layout (as mentioned by Bartosz Pieszko) 2) Better variable names 3) Added comments 4) Corrected spelling mistakes 5) Created a function pass_or_fail () to make code clearer 6) Found issue (see FIXME section in comments) Other points: 7) You did a code review (us), that's a good professional move 8) You could write unit tests, to test code https://code.sololearn.com/cwzT0YziQI8X/?ref=app It can be improved further, especially what to do with bad data. This input will give a divide by zero problem: int [] markArray = {}; Also, instead of putting all your functionality into main(), create a new function, and call that from main. Create a function that can be unit tested.
7th Apr 2018, 12:29 AM
Emma
0
No way dude lol. I spent an hour answering and gave much more details! 😂
7th Apr 2018, 9:32 AM
Emma