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
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?
I'm not familiar with that one yet..
Modulus gives the remainder.
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) ________________ ;
``` void set (int k) ``` Void methods don't return any value. a, b, and c all return a value.
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 ```
Wait, sorry typo. * x != 5 && y <= 2
guys, can you please go faster, i'm giving you as much time as I am able :)
x = y; else x = z Do I put this as the code??? What is it in code? :)
he gave you the logic "If y is less than z, x=y, otherwise z is the smaller number"
I see that :) I'm just trying to convert logic into code. The conversion is a little tough
Join our real-time social learning platform and learn together with your friends!