Assignment implementation
Check out, review, and merge locally
Step 1. Fetch and check out the branch for this merge request
git fetch origin git checkout b dev origin/dev
Step 2. Review the changes locally
Step 3. Merge the branch and fix any conflicts that come up
git checkout master git merge noff dev
Step 4. Push the result of the merge to GitLab
git push origin master
Note that pushing to GitLab requires write access to this repository.
Tip: You can also checkout merge requests locally by following these guidelines.

Task1.java 0 → 100644
1 import java.util.Scanner; 2 3 public class Task1 { 4 public static void main(String[] args) { 5 6 7 //  write your code BELOW this line only  8 // your code here (add lines) 9 10 Scanner myScanner = new Scanner(System.in); 
Remoba @remoba999 commentedMaster
myScanner is a pretty bad name. The "my" prefix adds nothing to the name and is redundant. If it's acceptable by the university, it's fine, but I would never leave it in. Simply calling it "scanner" is much better
myScanner is a pretty bad name. The "my" prefix adds nothing to the name and is redundant. If it's acceptable by the university, it's fine, but I would never leave it in. Simply calling it "scanner" is much better 
Naor Kolet @Naorko commented
They always name it like that at the class and we even don't know what it is exactly so I think it's okay
They always name it like that at the class and we even don't know what it is exactly so I think it's okay 
Remoba @remoba999 commentedMaster
They are bad and they should feel bad, but ok
They are bad and they should feel bad, but ok
Please register or sign in to reply 

Task1.java 0 → 100644
1 import java.util.Scanner; 2 3 public class Task1 { 4 public static void main(String[] args) { 5 6 7 //  write your code BELOW this line only  8 // your code here (add lines) 9 10 Scanner myScanner = new Scanner(System.in); 11 int number1 = myScanner.nextInt(); 
Remoba @remoba999 commentedMaster
I never use numbers when naming variables, only alphabetical characters, it's a standard that exists in pretty much every language and is there to avoid confusion. Since this is just an exercise and there's really NO logical meaning to these numbers I will let it pass
I never use numbers when naming variables, only alphabetical characters, it's a standard that exists in pretty much every language and is there to avoid confusion. Since this is just an exercise and there's really NO logical meaning to these numbers I will let it pass 
Naor Kolet @Naorko commented
Confusion with what? so it better be numberA and numberB..?
Confusion with what? so it better be numberA and numberB..? 
Remoba @remoba999 commentedMaster
It's complicated, but stuff can be misunderstood by people. For example consider the following:
int 3L = 4; int a = 3L;
Is the value of a now 4 or 3? (3L as a literal means 3 as a Long)
This only applies for variables that start with a digit, but you get my point.
Anyway, again, since this is how they taught you, leave it like that
It's complicated, but stuff can be misunderstood by people. For example consider the following: ` int 3L = 4; int a = 3L; ` Is the value of a now 4 or 3? (3L as a literal means 3 as a Long) This only applies for variables that start with a digit, but you get my point. Anyway, again, since this is how they taught you, leave it like that 
Remoba @remoba999
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in [version 2 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732#ebe01094808e32482e9f976cb5963ed309154f0e_11_11)Toggle commit list


Task1.java 0 → 100644
1 import java.util.Scanner; 2 3 public class Task1 { 4 public static void main(String[] args) { 5 6 7 //  write your code BELOW this line only  8 // your code here (add lines) 9 10 Scanner myScanner = new Scanner(System.in); 11 int number1 = myScanner.nextInt(); 12 int number2 = myScanner.nextInt(); 13 int number3 = myScanner.nextInt(); 14 15 // Make sure number1 is smaller than number2 16 if (number1 > number2){ 
Remoba @remoba999 commentedMaster
You're missing a space character before the curly brace ({)
You're missing a space character before the curly brace ({) 
Remoba @remoba999
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in [version 2 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732#ebe01094808e32482e9f976cb5963ed309154f0e_16_11)Toggle commit list


Task1.java 0 → 100644
9 10 Scanner myScanner = new Scanner(System.in); 11 int number1 = myScanner.nextInt(); 12 int number2 = myScanner.nextInt(); 13 int number3 = myScanner.nextInt(); 14 15 // Make sure number1 is smaller than number2 16 if (number1 > number2){ 17 int tmp = number1; 18 number1 = number2; 19 number2 = tmp; 20 } 21 22 // Make sure number2 is smaller than number3 23 if (number2 > number3) { 24 int tmp1 = number2; 
Remoba @remoba999 commentedMaster
Why define 3 temporary variables when you can use the same one every time?
Why define 3 temporary variables when you can use the same one every time? 
Naor Kolet @Naorko commented
They die in their little scope individually so I thought it's okay\better. I will change it
They die in their little scope individually so I thought it's okay\better. I will change it 
Remoba @remoba999
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in [version 2 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732#ebe01094808e32482e9f976cb5963ed309154f0e_24_24)Toggle commit list


Task2.java 0 → 100644
1 import java.util.Scanner; 2 3 public class Task2 { 4 public static void main(String[] args) { 5 6 //  write your code BELOW this line only  7 // your code here (add lines) 8 9 Scanner myScanner = new Scanner(System.in); 10 int number = myScanner.nextInt(); 11 12 int divisor = 2; 13 // Check the divisors from 2 to number sqrt 
Remoba @remoba999 commentedMaster
I would add an empty line before the comment. number sqrt? Why are you shortening your comment? This isn't a variable name. A better comment would be "Iterating over possible divisors from 2 to the number's square root"
I would add an empty line before the comment. number sqrt? Why are you shortening your comment? This isn't a variable name. A better comment would be "Iterating over possible divisors from 2 to the number's square root" 
Naor Kolet @Naorko commented
Because my English is not so good, and you are here to make it better. I fixed the comment
Because my English is not so good, and you are here to make it better. I fixed the comment 
Remoba @remoba999
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in [version 2 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732#536d400a579e15cb45933e34db8e4c30ee7852cd_13_13)Toggle commit list


Task2.java 0 → 100644
1 import java.util.Scanner; 2 3 public class Task2 { 4 public static void main(String[] args) { 5 6 //  write your code BELOW this line only  7 // your code here (add lines) 8 9 Scanner myScanner = new Scanner(System.in); 10 int number = myScanner.nextInt(); 11 12 int divisor = 2; 13 // Check the divisors from 2 to number sqrt 14 // The divisors will only be primes according to Unique Factorization Theorem 15 while ( divisor * divisor <= number ) { 
Remoba @remoba999 commentedMaster
There's no need for empty characters after and before parentheses
There's no need for empty characters after and before parentheses 
Naor Kolet @Naorko commented
Like that. Right? while (divisor * divisor <= number) {
Like that. Right? while (divisor * divisor <= number) { 
Remoba @remoba999 commentedMaster
Yup
Yup 
Remoba @remoba999
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in [version 2 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732#536d400a579e15cb45933e34db8e4c30ee7852cd_15_16)Toggle commit list


Task2.java 0 → 100644
1 import java.util.Scanner; 2 3 public class Task2 { 4 public static void main(String[] args) { 5 6 //  write your code BELOW this line only  7 // your code here (add lines) 8 9 Scanner myScanner = new Scanner(System.in); 10 int number = myScanner.nextInt(); 11 12 int divisor = 2; 13 // Check the divisors from 2 to number sqrt 14 // The divisors will only be primes according to Unique Factorization Theorem 
Remoba @remoba999 commentedMaster
What? Primes? What do you mean? What does that have to do with the while block? I realize only prime numbers would be suitable divisors, but why state that here?
What? Primes? What do you mean? What does that have to do with the while block? I realize only prime numbers would be suitable divisors, but why state that here? 
Naor Kolet @Naorko commented
At class we saw an algorithm to check whether a number is prime or not. at the assignment they let us know about the unique factorization so I thought it is needed to state why I don't check whether my divisor is prime or not.
They also told us to state at the comments the mathematical algorithm we base the code
so it is needed or not?
At class we saw an algorithm to check whether a number is prime or not. at the assignment they let us know about the unique factorization so I thought it is needed to state why I don't check whether my divisor is prime or not. They also told us to state at the comments the mathematical algorithm we base the code so it is needed or not? 
Remoba @remoba999 commentedMaster
It's just out of place, I don't see why it's needed. But you can leave it in, it doesn't matter
It's just out of place, I don't see why it's needed. But you can leave it in, it doesn't matter


Task2.java 0 → 100644
1 import java.util.Scanner; 2 3 public class Task2 { 4 public static void main(String[] args) { 5 6 //  write your code BELOW this line only  7 // your code here (add lines) 8 9 Scanner myScanner = new Scanner(System.in); 10 int number = myScanner.nextInt(); 11 12 int divisor = 2; 13 // Check the divisors from 2 to number sqrt 14 // The divisors will only be primes according to Unique Factorization Theorem 15 while ( divisor * divisor <= number ) { 16 // If divides, print the divisor and divide it from number 
Remoba @remoba999 commentedMaster
That's broken English, it should be "If divisible" and also there's a missing "the" before the final word (number)
That's broken English, it should be "If divisible" and also there's a missing "the" before the final word (number) 
Naor Kolet @Naorko commented
Fixed it
Fixed it 
Remoba @remoba999
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in [version 2 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732#536d400a579e15cb45933e34db8e4c30ee7852cd_16_16)Toggle commit list


Task2.java 0 → 100644
4 public static void main(String[] args) { 5 6 //  write your code BELOW this line only  7 // your code here (add lines) 8 9 Scanner myScanner = new Scanner(System.in); 10 int number = myScanner.nextInt(); 11 12 int divisor = 2; 13 // Check the divisors from 2 to number sqrt 14 // The divisors will only be primes according to Unique Factorization Theorem 15 while ( divisor * divisor <= number ) { 16 // If divides, print the divisor and divide it from number 17 if ( number % divisor == 0 ) { 18 System.out.println(divisor); 19 number = number / divisor; 
Remoba @remoba999 commentedMaster
Why not use /= ?
Why not use /= ? 
Naor Kolet @Naorko commented
Wasn't tought in class
Wasn't tought in class 
Remoba @remoba999 commentedMaster
k
k 
Remoba @remoba999
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in [version 2 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732#536d400a579e15cb45933e34db8e4c30ee7852cd_19_20)Toggle commit list


Task2.java 0 → 100644
7 // your code here (add lines) 8 9 Scanner myScanner = new Scanner(System.in); 10 int number = myScanner.nextInt(); 11 12 int divisor = 2; 13 // Check the divisors from 2 to number sqrt 14 // The divisors will only be primes according to Unique Factorization Theorem 15 while ( divisor * divisor <= number ) { 16 // If divides, print the divisor and divide it from number 17 if ( number % divisor == 0 ) { 18 System.out.println(divisor); 19 number = number / divisor; 20 } 21 // Advance divisor only if it's not divide for identical divisors like 20=2*2*5 22 else 
Remoba @remoba999 commentedMaster
The else should start at the same line as the ending curly brace (}). Also move the comment to be above the actual line that increments
The else should start at the same line as the ending curly brace (}). Also move the comment to be above the actual line that increments 
Naor Kolet @Naorko commented
Correct it to this: if ( number % divisor == 0 ) { System.out.println(divisor); number = number / divisor; } else // Only increment the divisor when it no longer divides the number divisor = divisor + 1;
Correct it to this: if ( number % divisor == 0 ) { System.out.println(divisor); number = number / divisor; } else // Only increment the divisor when it no longer divides the number divisor = divisor + 1; 
Remoba @remoba999
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in [version 2 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732#536d400a579e15cb45933e34db8e4c30ee7852cd_22_20)Toggle commit list


Task2.java 0 → 100644
8 9 Scanner myScanner = new Scanner(System.in); 10 int number = myScanner.nextInt(); 11 12 int divisor = 2; 13 // Check the divisors from 2 to number sqrt 14 // The divisors will only be primes according to Unique Factorization Theorem 15 while ( divisor * divisor <= number ) { 16 // If divides, print the divisor and divide it from number 17 if ( number % divisor == 0 ) { 18 System.out.println(divisor); 19 number = number / divisor; 20 } 21 // Advance divisor only if it's not divide for identical divisors like 20=2*2*5 22 else 23 divisor = divisor + 1; 
Remoba @remoba999 commentedMaster
Why not use ++?
Why not use ++? 
Naor Kolet @Naorko commented
okay okay, I will use the ++ and /=
okay okay, I will use the ++ and /= 
Remoba @remoba999 commentedMaster
Yay
Yay 
Remoba @remoba999
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in [version 2 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732#536d400a579e15cb45933e34db8e4c30ee7852cd_23_20)Toggle commit list


Task2.java 0 → 100644
10 int number = myScanner.nextInt(); 11 12 int divisor = 2; 13 // Check the divisors from 2 to number sqrt 14 // The divisors will only be primes according to Unique Factorization Theorem 15 while ( divisor * divisor <= number ) { 16 // If divides, print the divisor and divide it from number 17 if ( number % divisor == 0 ) { 18 System.out.println(divisor); 19 number = number / divisor; 20 } 21 // Advance divisor only if it's not divide for identical divisors like 20=2*2*5 22 else 23 divisor = divisor + 1; 24 } 25 // Print the last Prime divisor which wasn't printed because it's above the square, Or the number is originally prime number 
Remoba @remoba999 commentedMaster
Missing empty line after the ending curly brace. Also, if the number isn't prime, it will always end up printing "1" right? Is that what you want? And what do you mean in "above the square"? Am I missing something or is that not possible by definition?
Missing empty line after the ending curly brace. Also, if the number isn't prime, it will always end up printing "1" right? Is that what you want? And what do you mean in "above the square"? Am I missing something or is that not possible by definition? 
Naor Kolet @Naorko commented
1 will not be printed and I need it that way. When I check for divisors I take the number and start checking form 2 to the square (according to what defined in class, if there are divisors for a number it will always have one of them equal and below the square. I always divide the number by the divisor I found so the quotient at the end will be the other divisor which I cant reach in the iteration.
How can I be more clear about it in the code? Maybe change it someway?
1 will not be printed and I need it that way. When I check for divisors I take the number and start checking form 2 to the square (according to what defined in class, if there are divisors for a number it will always have one of them equal and below the square. I always divide the number by the divisor I found so the quotient at the end will be the other divisor which I cant reach in the iteration. How can I be more clear about it in the code? Maybe change it someway? 
Remoba @remoba999 commentedMaster
So when exiting the loop, the "number" variable holds the final divisor right? Just state that in a comment
So when exiting the loop, the "number" variable holds the final divisor right? Just state that in a comment 
Naor Kolet @Naorko commented
what should I write?
what should I write? 
Remoba @remoba999 commentedMaster
"The remaining number is the final divisor"
"The remaining number is the final divisor" 
Remoba @remoba999
changed this line in version 4 of the diff
changed this line in version 4 of the diff
changed this line in [version 4 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8333895&start_sha=9dbd9eff626b3ba877f2db9024347502f647f040#536d400a579e15cb45933e34db8e4c30ee7852cd_27_27)Toggle commit list


Task2.java 0 → 100644
6 //  write your code BELOW this line only  7 // your code here (add lines) 8 9 Scanner myScanner = new Scanner(System.in); 10 int number = myScanner.nextInt(); 11 12 int divisor = 2; 13 // Check the divisors from 2 to number sqrt 14 // The divisors will only be primes according to Unique Factorization Theorem 15 while ( divisor * divisor <= number ) { 16 // If divides, print the divisor and divide it from number 17 if ( number % divisor == 0 ) { 18 System.out.println(divisor); 19 number = number / divisor; 20 } 21 // Advance divisor only if it's not divide for identical divisors like 20=2*2*5 
Remoba @remoba999 commentedMaster
The comment is really unclear due to broken English. A better comment would be "Only increment the divisor when it no longer divides the number"
The comment is really unclear due to broken English. A better comment would be "Only increment the divisor when it no longer divides the number" 
Remoba @remoba999
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in [version 2 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732#536d400a579e15cb45933e34db8e4c30ee7852cd_21_20)Toggle commit list


Task3.java 0 → 100644
8 // your code here (add lines) 9 Scanner myScanner = new Scanner(System.in); 10 int numer1 = myScanner.nextInt(); 11 int denom1 = myScanner.nextInt(); 12 int numer2 = myScanner.nextInt(); 13 int denom2 = myScanner.nextInt(); 14 15 // Calculate the numerator and denominator of the result summary 16 int numer = numer1 * denom2 + denom1 * numer2; 17 int denom = denom1 * denom2; 18 19 // Executing the Euclidean algorithm for GCD of the numerator and denominator for fraction reduction 20 int number1 = numer; 21 int number2 = denom; 22 int r = number1 % number2; 23 while (r != 0) { 
Remoba @remoba999 commentedMaster
Missing empty line before the while block
Missing empty line before the while block 
Remoba @remoba999
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in [version 2 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732#de77382d0c2451dafbdb977c60d13fba0bf3c50d_23_20)Toggle commit list 
Naor Kolet @Naorko commented
Done
Done


Task3.java 0 → 100644
7 //  write your code BELOW this line only  8 // your code here (add lines) 9 Scanner myScanner = new Scanner(System.in); 10 int numer1 = myScanner.nextInt(); 11 int denom1 = myScanner.nextInt(); 12 int numer2 = myScanner.nextInt(); 13 int denom2 = myScanner.nextInt(); 14 15 // Calculate the numerator and denominator of the result summary 16 int numer = numer1 * denom2 + denom1 * numer2; 17 int denom = denom1 * denom2; 18 19 // Executing the Euclidean algorithm for GCD of the numerator and denominator for fraction reduction 20 int number1 = numer; 21 int number2 = denom; 22 int r = number1 % number2; 
Remoba @remoba999 commentedMaster
While I personally know the algorithm, a variable named "r" is simple not readable. Maybe rename it to something like "remainder"
While I personally know the algorithm, a variable named "r" is simple not readable. Maybe rename it to something like "remainder" 
Naor Kolet @Naorko commented
change it, but in class they called it r
change it, but in class they called it r 
Remoba @remoba999
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in [version 2 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732#de77382d0c2451dafbdb977c60d13fba0bf3c50d_22_20)Toggle commit list


Task3.java 0 → 100644
14 15 // Calculate the numerator and denominator of the result summary 16 int numer = numer1 * denom2 + denom1 * numer2; 17 int denom = denom1 * denom2; 18 19 // Executing the Euclidean algorithm for GCD of the numerator and denominator for fraction reduction 20 int number1 = numer; 21 int number2 = denom; 22 int r = number1 % number2; 23 while (r != 0) { 24 number1 = number2; 25 number2 = r; 26 r = number1 % number2; 27 } 28 29 // number2 is the GCD 
Remoba @remoba999 commentedMaster
I was expecting a comment like "Reduce the result fraction"
I was expecting a comment like "Reduce the result fraction" 
Remoba @remoba999
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in [version 2 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732#de77382d0c2451dafbdb977c60d13fba0bf3c50d_29_29)Toggle commit list 
Naor Kolet @Naorko commented
already changed that, it is comitted?
already changed that, it is comitted?


Task4.java 0 → 100644
2 3 public class Task4 { 4 public static void main(String[] args) { 5 6 //  write your code BELOW this line only  7 // your code here (add lines) 8 Scanner myScanner = new Scanner(System.in); 9 int numerIn = myScanner.nextInt(); 10 int denomIn = myScanner.nextInt(); 11 12 int numerOut = numerIn; 13 int denomOut = denomIn; 14 15 numerIn = myScanner.nextInt(); 16 //Get inputs until 1, calculate the summery each loop 17 while (numerIn != 1) { 
Remoba @remoba999 commentedMaster
Have you learned about constants or macros? What you have here is often called "magic numbers" and is a bad practice. Also, your format for comments up until now was "// abc" and not "//abc", do the same here
Have you learned about constants or macros? What you have here is often called "magic numbers" and is a bad practice. Also, your format for comments up until now was "// abc" and not "//abc", do the same here 
Naor Kolet @Naorko commented
Didn't quite understand what you said about "magic numbers"
Didn't quite understand what you said about "magic numbers" 
Remoba @remoba999 commentedMaster
Basically when you have random literals in your code with no context it's weird and unreadable. You want code that is as readable as English, so something like
while (inputNumber != STOP_INPUT)
is much more readable, don't you agree?
But again, if they hadn't taught you that yet, leave it as it is
Basically when you have random literals in your code with no context it's weird and unreadable. You want code that is as readable as English, so something like `while (inputNumber != STOP_INPUT)` is much more readable, don't you agree? But again, if they hadn't taught you that yet, leave it as it is 
Naor Kolet @Naorko commented
much nicer, I can create a new variable for this, but they didn't talked and declared what is a constants such as
final int STOP_INPUT = 1;
much nicer, I can create a new variable for this, but they didn't talked and declared what is a constants such as `final int STOP_INPUT = 1;` 
Remoba @remoba999 commentedMaster
If they taught you the "final" keyword, use it. Otherwise, leave it as it is and resolve this discussion
If they taught you the "final" keyword, use it. Otherwise, leave it as it is and resolve this discussion 
Naor Kolet @Naorko commented
resolve this. I will leave it like that
resolve this. I will leave it like that


Task4.java 0 → 100644
10 int denomIn = myScanner.nextInt(); 11 12 int numerOut = numerIn; 13 int denomOut = denomIn; 14 15 numerIn = myScanner.nextInt(); 16 //Get inputs until 1, calculate the summery each loop 17 while (numerIn != 1) { 18 denomIn = myScanner.nextInt(); 19 // Calculate the numerator and denominator of the result summary 20 numerOut = numerIn * denomOut + denomIn * numerOut; 21 denomOut = denomIn * denomOut; 22 23 numerIn = myScanner.nextInt(); 24 } 25 // Executing the Euclidean algorithm for GCD of the numerator and denominator for fraction reduction 
Remoba @remoba999 commentedMaster
Missing empty line after the ending curly brace. Also, are they fine with you only reducing the fraction after finishing? You can easily get a numerical overflow if you get too many inputs, but I guess that's too heavy for you right now so never mind
Missing empty line after the ending curly brace. Also, are they fine with you only reducing the fraction after finishing? You can easily get a numerical overflow if you get too many inputs, but I guess that's too heavy for you right now so never mind 
Naor Kolet @Naorko commented
I did thought about putting the GCD algorithm in the iteration, what do you think it should be?
I did thought about putting the GCD algorithm in the iteration, what do you think it should be? 
Remoba @remoba999 commentedMaster
Ideally you would want it in every iteration to avoid an overflow
Ideally you would want it in every iteration to avoid an overflow 
Naor Kolet @Naorko commented
Moved it to the inside the iteration, but what will happen if the user will enter 1 fraction who need the reduction? like 8 4 1
So I have the same algorithm of gcd in my code :\
Moved it to the inside the iteration, but what will happen if the user will enter 1 fraction who need the reduction? like 8 4 1 So I have the same algorithm of gcd in my code :\ 
Remoba @remoba999 commentedMaster
Normally you would use a function and just call it once before starting and once in the loop. Since you're not using functions, you kinda have to have the same code twice. If you think they will take off points for that, leave it like you did it originally. I have no idea what you're scored for
Normally you would use a function and just call it once before starting and once in the loop. Since you're not using functions, you kinda have to have the same code twice. If you think they will take off points for that, leave it like you did it originally. I have no idea what you're scored for 
Remoba @remoba999
changed this line in version 3 of the diff
changed this line in version 3 of the diff
changed this line in [version 3 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8332874&start_sha=9eee9ad5901547ea337dba6f6d8b21878e02899d#53f394dc13c65652f285721cce1bb679fbb29bf3_27_42)Toggle commit list 
Naor Kolet @Naorko commented
The code should be short and elegant. I guess I will know when I will get the grade
The code should be short and elegant. I guess I will know when I will get the grade


Task4.java 0 → 100644
14 15 numerIn = myScanner.nextInt(); 16 //Get inputs until 1, calculate the summery each loop 17 while (numerIn != 1) { 18 denomIn = myScanner.nextInt(); 19 // Calculate the numerator and denominator of the result summary 20 numerOut = numerIn * denomOut + denomIn * numerOut; 21 denomOut = denomIn * denomOut; 22 23 numerIn = myScanner.nextInt(); 24 } 25 // Executing the Euclidean algorithm for GCD of the numerator and denominator for fraction reduction 26 int number1 = numerOut; 27 int number2 = denomOut; 28 int r = number1 % number2; 29 while (r != 0) { 
Remoba @remoba999 commentedMaster
Missing empty line before and after the while loop. Same comments as before about the stopping input and about the variable names
Missing empty line before and after the while loop. Same comments as before about the stopping input and about the variable names 
Remoba @remoba999
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in [version 2 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732#53f394dc13c65652f285721cce1bb679fbb29bf3_29_28)Toggle commit list


Task6.java 0 → 100644
16 int a = myScanner.nextInt(); 17 int b = myScanner.nextInt(); 18 int c = myScanner.nextInt(); 19 int d = myScanner.nextInt(); 20 21 // Make a and b the smallest numbers 22 23 // Make sure that a is smaller than b 24 if (a > b) { 25 int tmp = a; 26 a = b; 27 b = tmp; 28 } 29 // Make sure that b is smaller than c 30 if (b > c) { 31 int tmp1 = b; 
Remoba @remoba999 commentedMaster
Again, really no need to use different temporary variables
Again, really no need to use different temporary variables 
Remoba @remoba999
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in [version 2 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732#c584759a35341629ace979bb300096be5df3ad44_31_33)Toggle commit list


Task7.java 0 → 100644
1 // You may not change or erase any of the lines and comments 2 // in this file. You may only add lines. 3 4 public class Task7 { 5 6 7 public static void main(String[] args) { 8 9 10 //  write any code BELOW this line only  11 // your code here (add lines) 12 boolean isVerified = true; 13 int i = 0, j = 0, k = 0, l = 0; 
Remoba @remoba999 commentedMaster
You're already initializing every index var inside the blocks, the only one you should really initialize here is the first one (i). But I guess that's not even your code right?
You're already initializing every index var inside the blocks, the only one you should really initialize here is the first one (i). But I guess that's not even your code right? 
Naor Kolet @Naorko commented
LOL, Its my code! but if I don't initialize them the compiler yell at me because I print them at the end
LOL, Its my code! but if I don't initialize them the compiler yell at me because I print them at the end 
Remoba @remoba999 commentedMaster
You're right, my bad.
The reason the compiler "yells" at you is because that while block is dependent on the conditional, so it can possible have 0 iterations, meaning there's a case where the variables won't be initialized by the time you get to printing them. That's why you have to give them starting values
You're right, my bad. The reason the compiler "yells" at you is because that while block is dependent on the conditional, so it can possible have 0 iterations, meaning there's a case where the variables won't be initialized by the time you get to printing them. That's why you have to give them starting values 
Naor Kolet @Naorko commented
So it is ok to leave it like that? or can I change the code someway to be more elegant?
So it is ok to leave it like that? or can I change the code someway to be more elegant? 
Remoba @remoba999 commentedMaster
Leave it, I guess, that's the price you have to pay when you don't use functions. If you could use functions I would just created a function called "isVerified", replace the while loops with for loops and just return instead of setting "false". Would be much cleaner
Leave it, I guess, that's the price you have to pay when you don't use functions. If you could use functions I would just created a function called "isVerified", replace the while loops with for loops and just return instead of setting "false". Would be much cleaner 
Remoba @remoba999
changed this line in version 4 of the diff
changed this line in version 4 of the diff
changed this line in [version 4 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8333895&start_sha=9dbd9eff626b3ba877f2db9024347502f647f040#2065c8639d4949bd0a229d0d683eb3ceb49f961e_13_13)Toggle commit list


Task7.java 0 → 100644
63 } 64 65 //  end of copied code from Task 6 66 67 68 //  write any code BELOW this line only  69 // your code here (add lines) 70 71 if (a + b + c + d == 2) { 72 if (a + b != 0) { 73 isVerified = false; 74 } 75 } else if ((a + b + c + d) / 2 != a + b) { 76 isVerified = false; 77 } 78 l = l + 1; 
Remoba @remoba999 commentedMaster
Add an empty line after each ending curly
Add an empty line after each ending curly 
Remoba @remoba999
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in [version 2 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732#2065c8639d4949bd0a229d0d683eb3ceb49f961e_78_75)Toggle commit list


Task7.java 0 → 100644
56 } 57 58 // Make sure that b is smaller than d 59 if (b > d) { 60 int tmp = b; 61 b = d; 62 d = tmp; 63 } 64 65 //  end of copied code from Task 6 66 67 68 //  write any code BELOW this line only  69 // your code here (add lines) 70 71 if (a + b + c + d == 2) { 
Remoba @remoba999 commentedMaster
I am sure your conditionals work, but they are so random... If this is meant to test your code, why not just explicitly check if a and b are truly the lowest numbers? (a < c && a < d && b < c && b < d)  Is that not allowed? Because that's how you write actual tests
I am sure your conditionals work, but they are so random... If this is meant to test your code, why not just explicitly check if a and b are truly the lowest numbers? (a < c && a < d && b < c && b < d)  Is that not allowed? Because that's how you write actual tests 
Naor Kolet @Naorko commented
Changed it to this: if (a > c  a > d  b > c  b > d) { isVerified = false; }
btw, it IS forbidden to use  and && without an actually reason for it
Changed it to this: if (a > c  a > d  b > c  b > d) { isVerified = false; } btw, it IS forbidden to use  and && without an actually reason for it 
Remoba @remoba999
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in [version 2 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732#2065c8639d4949bd0a229d0d683eb3ceb49f961e_71_72)Toggle commit list 
Remoba @remoba999 commentedMaster
 is not . It's a bitwise OR. Does this even compile?
 is not . It's a bitwise OR. Does this even compile? 
Remoba @remoba999 commentedMaster
Apparently that's the way you were taught. The way I see it, that operator shouldn't be ever used. Just consider the following conditional:
if (myList == null  myList.isEmpty()) { // do stuff }
This will work perfectly even when
myList
is null.But if you use  instead, and
myList
happens to be null, the first condition will be resolved astrue
, and then the second condition will be executed butmyList
is null, so the program will crash with an unexpected NullPointerExceptionIf that's what they make you do, so be it, but you should know never to use it
Apparently that's the way you were taught. The way I see it, that operator shouldn't be ever used. Just consider the following conditional: `if (myList == null  myList.isEmpty()) { // do stuff }` This will work perfectly even when `myList` is null. But if you use  instead, and `myList` happens to be null, the first condition will be resolved as `true`, and then the second condition will be executed but `myList` is null, so the program will crash with an unexpected NullPointerException If that's what they make you do, so be it, but you should know never to use it


Task7.java 0 → 100644
56 } 57 58 // Make sure that b is smaller than d 59 if (b > d) { 60 int tmp = b; 61 b = d; 62 d = tmp; 63 } 64 65 //  end of copied code from Task 6 66 67 68 //  write any code BELOW this line only  69 // your code here (add lines) 70 71 if (a + b + c + d == 2) { 
Remoba @remoba999 commentedMaster
I am sure your conditionals work, but they are so random... If this is meant to test your code, why not just explicitly check if a and b are truly the lowest numbers? (a < c && a < d && b < c && b < d)  Is that not allowed? Because that's how you write actual tests
I am sure your conditionals work, but they are so random... If this is meant to test your code, why not just explicitly check if a and b are truly the lowest numbers? (a < c && a < d && b < c && b < d)  Is that not allowed? Because that's how you write actual tests 
Naor Kolet @Naorko commented
no need to yell at me twice
no need to yell at me twice 
Remoba @remoba999
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in [version 2 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732#2065c8639d4949bd0a229d0d683eb3ceb49f961e_71_72)Toggle commit list


Remoba @remoba999
added 1 commit
 9eee9ad5  Niko's changes
added 1 commit * 9eee9ad5  Niko's changes [Compare with previous version](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8331088&start_sha=0c1ce67c6bcf508756fe8429eb938419a2ae1732)Toggle commit list 
13 14 // Iterating over possible divisors from 2 to the number's square root 14 15 // The divisors will only be primes according to Unique Factorization Theorem 15 while ( divisor * divisor <= number ) { 16 // If divides, print the divisor and divide it from number 16 while (divisor * divisor <= number) { 17 // If divisible, print the divisor and divide it from the number 17 18 if ( number % divisor == 0 ) { 18 19 System.out.println(divisor); 19 number = number / divisor; 20 } 21 // Advance divisor only if it's not divide for identical divisors like 20=2*2*5 22 else 23 divisor = divisor + 1; 20 number /= divisor; 21 } else 
Remoba @remoba999 commentedMaster
A 1 liner? NO SIR. Surround that "divisor++" with a block please
A 1 liner? NO SIR. Surround that "divisor++" with a block please 
Naor Kolet @Naorko commented
you remind me this song https://www.youtube.com/watch?v=PIh2xe4jnpk
you remind me this song https://www.youtube.com/watch?v=PIh2xe4jnpk 
Remoba @remoba999
changed this line in version 3 of the diff
changed this line in version 3 of the diff
changed this line in [version 3 of the diff](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8332874&start_sha=9eee9ad5901547ea337dba6f6d8b21878e02899d#536d400a579e15cb45933e34db8e4c30ee7852cd_21_21)Toggle commit list


Remoba @remoba999
added 1 commit
 9dbd9eff  Fixes
added 1 commit * 9dbd9eff  Fixes [Compare with previous version](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8332874&start_sha=9eee9ad5901547ea337dba6f6d8b21878e02899d)Toggle commit list 
Remoba @remoba999
added 1 commit
 ded25284  Hopefully final fixes
added 1 commit * ded25284  Hopefully final fixes [Compare with previous version](https://gitlab.com/remoba999/Assignment1/merge_requests/1/diffs?diff_id=8333895&start_sha=9dbd9eff626b3ba877f2db9024347502f647f040)Toggle commit list 
Remoba @remoba999
resolved all discussions
resolved all discussions
resolved all discussionsToggle commit list 
Remoba @remoba999
merged
merged
mergedToggle commit list 
Remoba @remoba999
mentioned in commit 68ffe40e
mentioned in commit 68ffe40e
mentioned in commit 68ffe40ef40d7c3faf3b0e5331f060713966d345Toggle commit list