Ask your own question, for FREE!
Computer Science 15 Online
OpenStudy (ellecullen):

Homework: A method has the heading "void set (int k)". Which of the following is a legal statement inside that method? a. return 5; b. return 5.0; c. return k +5; d. none of the above 2. Complete this coding to print exactly 3 numbers on every line: for (int k = 5; k < 65; k++) if ( ________________ == 1) System.out.println (" " + k); else System.out.print (" " + k); please help asap .More questions in comments

OpenStudy (opcode):

1. A (Possibly, I am unsure, sorry.) 2. ```java for (int k = 5; k < 65; k++) if ( k%3 == 1) System.out.println (" " + k); else System.out.print (" " + k); ``` The '%' operator is modulus, are you familiar with the operator?

OpenStudy (ellecullen):

I'm not familiar with that one yet..

OpenStudy (opcode):

Modulus gives the remainder.

OpenStudy (ellecullen):

Can you do this one: if (x==5 || y>2) is fully equivalent to if (! (______________)) || is or Complete this if-statement (you may use else) to assign to x the smaller of y and z: if (y < z) ________________ ;

OpenStudy (lyrae):

``` void set (int k) ``` Void methods don't return any value. a, b, and c all return a value.

OpenStudy (opcode):

3. It is fully equivalent to x != 5 && y >= 2. || is the logical operator of or. 4. Write this out. If y is less than z, what is smaller, and otherwise. ```java x = y; else x = z ```

OpenStudy (opcode):

Wait, sorry typo. * x != 5 && y <= 2

OpenStudy (ellecullen):

guys, can you please go faster, i'm giving you as much time as I am able :)

OpenStudy (ellecullen):

x = y; else x = z Do I put this as the code??? What is it in code? :)

OpenStudy (bibby):

he gave you the logic "If y is less than z, x=y, otherwise z is the smaller number"

OpenStudy (ellecullen):

I see that :) I'm just trying to convert logic into code. The conversion is a little tough

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!