+ 2
[OFF-TOPIC] I think mean I'm here
I can do my best https://code.sololearn.com/crHVVwaCwkc3/?ref=app
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");
+ 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.
0
No way dude lol. I spent an hour answering and gave much more details! đ