Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Task1-10 Vynnyk #9

wants to merge 3 commits into from

Conversation

VynnykVV
Copy link

No description provided.

@didva didva self-assigned this Nov 21, 2016
@@ -4,6 +4,23 @@
public class Task4 {

public static double getSumOfGreatest(double a, double b, double c) {
return 0;

double firstMax;
Copy link

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;}
Copy link

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));
Copy link

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.

Copy link

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));
Copy link

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);
Copy link

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);
Copy link

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;}
Copy link

@didva didva Nov 21, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants