Skip to content

Conversation

@anAstyQ
Copy link

@anAstyQ anAstyQ commented Nov 25, 2016

No description provided.

@didva didva self-assigned this Nov 25, 2016
Copy link

@didva didva left a 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)
Copy link

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

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Too many ().
  2. It's better to use && and || for current verifications. Please read about difference between || and |.
  3. 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){
Copy link

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

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

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

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<=0

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