-
Notifications
You must be signed in to change notification settings - Fork 12
homework1 #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
homework1 #10
Conversation
didva
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update PR
| public static boolean containDigitTwo(int a) { | ||
| boolean flag = false; | ||
| int aLast; | ||
| if(a == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need in this verification and assignment because your flag is already set to false.
| while((a/10) > 0){ | ||
| aLast = a%10; | ||
| a = a/10; | ||
| if((aLast == 2)|(a == 2)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to use || operator.
| int aLast; | ||
| if(a == 0) | ||
| flag = false; | ||
| while((a/10) > 0){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be just a > 0. And there will be no need in additional (a == 2) verification.
| public class Task3 { | ||
| public static boolean isBetween(int a, int b, int c) { | ||
| return false; | ||
| if (((b >= a)&(b <= c))|((b >= c)&(b <= a))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Too many
(). - It's better to use
&&and||for current verifications. Please read about difference between||and|. - Can be just
return ((b >= a)&(b <= c))|((b >= c)&(b <= a));because result is boolean type.
| return 0; | ||
| double x1; | ||
| double x2; | ||
| if (a >=b){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Math.max() for these purpose.
| public class Task5 { | ||
| public static double calculateA(double x, double y, double z) { | ||
| return 0; | ||
| double b = 1 + (Math.pow(z,2)/(3 + (Math.pow(z,2)/5))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be just double b = calculateB(z);
| public static double calculateS(double x) { | ||
| return 0d; | ||
|
|
||
| public int factorial(int n){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change it to public static int factorial(int n)
| return result; | ||
| } | ||
|
|
||
| public double calculateS(double x) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same, please add static modifier.
| public static double calculateSum(double N) { | ||
| double res = 0; | ||
| int i; | ||
| for(i=0; i <(N+1); i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be simpler: for(int i = 0; ...)
| public static boolean isPowerOfThree(int n) { | ||
| return false; | ||
| boolean flag = true; | ||
| if(n == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<=0
No description provided.