Skip to content

Conversation

@VynnykVV
Copy link

No description provided.

@didva didva self-assigned this Nov 21, 2016
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.

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.

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 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.


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