Sector Four

4.01 - if (x == true || y == true){
return true;
}
return false;
4.02 - if(x == false || y == false){
return false;
}
return true;
4.03 - if (x < 50){
 return true;
 }
 return false;
4.04 - if(x >= y){
return false;
    }
return true;
4.05 -  if(i < 0){
return -1;
}
if(i > 0){
return 1;
}
return 0;
4.06 - if(i == j){
return true;
}
return false;
4.07 - if(i > 99){
return 3;
}
return 2;
4.08 - if(i % 2 == 0){
return "even";
}
return "odd";
4.09 - if(i % 5 == 0){
return "multiple of 5";
}
return "not a multiple of 5";
4.10 - if(i % x == 0){
return "multiple of " + x;
}
return "not a multiple of " + x;
4.11 - if(i % 4 == 0 && i == (j*2) && j % 2 == 0 && k == (j/2)){
return "yes!";
}
return "no";
4.12 - int output = 21;
        if(i <= 7){
                return 0;
        }
if(i > 7 && i <= 14){
        return 7;
}
return output;

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. 4.01 x || y
    4.02 x && y
    4.03 x < 50
    4.04 x < y
    4.05 (i == 0) ? 0 : Math.Abs(i)/i
    4.06 i > j
    4.07 (i < 100 ? 2 : 3)
    4.08 (i % 2 == 0 ? "even" : "odd")
    4.09 (i % 5 == 0 ? "" : "not a ") + "multiple of 5"
    4.10 (i % x == 0 ? "" : "not a ") + "multiple of " + x
    4.11 ((i/(double)j == j/(double)k && (i!=j)) ? "yes!" : "no")
    4.12 (i < 8 ? 0 : i < 15 ? 7 : 21)

    ReplyDelete