-
Notifications
You must be signed in to change notification settings - Fork 13
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
Task1-10 Vynnyk #9
base: master
Are you sure you want to change the base?
Conversation
@@ -4,6 +4,23 @@ | |||
public class Task4 { | |||
|
|||
public static double getSumOfGreatest(double a, double b, double c) { | |||
return 0; | |||
|
|||
double firstMax; |
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 too complicated.
You can go from the back side, find the smallest number in one if
statement and return summ of the others.
@@ -2,6 +2,10 @@ | |||
|
|||
public class Task3 { | |||
public static boolean isBetween(int a, int b, int c) { | |||
return false; | |||
if (a==b||b==c){return true;} |
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.
You can use <=
, >=
operators instead of this condition.
@@ -3,10 +3,16 @@ | |||
|
|||
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.
The idea was to use smth like double b = calculateB(z)
, but it's ok for now.
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 most case it's better to extract duplicated calculations into variable. So, please extract Math.pow(z, 2)
.
public class Task6 { | ||
public static double calculateS(double x) { | ||
return 0d; | ||
|
||
double s=1+x+(Math.pow(x,2)/(2*1))+(Math.pow(x,3)/(3*2*1))+(Math.pow(x,4)/(4*3*2*1)); |
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.
Not needed variable.
} | ||
|
||
public static double calculateZ(double x, double y) { | ||
return 0d; | ||
double z=Math.sin(Math.pow(x,3))+Math.pow(Math.cos(y),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.
The same as above.
double sum=0; | ||
for (int i = 0; i <= N; i++) { | ||
|
||
b = Math.pow(N + i, 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.
You can do it without variable b
.
@@ -3,6 +3,14 @@ | |||
public class Task9 { | |||
|
|||
public static boolean isPowerOfThree(int n) { | |||
if (n==1){return true;} | |||
if (n==0){return false;} |
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.
I'd prefer n <= 0
for this.
No description provided.