**MEDAL + FAN** I'm struggling in Java Programming. Could somebody break these down for me? I don't understand the questions. (Also, this assignment doesn't weight on my grade. I just need to get the content down.)
I would say random int between 0 and 10, for the first question.
Question #3, I believe the answer to be "else".
Thanks. Can you help me with the others? And could you maybe explain how you identify the answers to question 1 and 3? It's fine if you can't/don't want to.
@Ghyst
In Java most language specific questions can be answered by consulting the Java API documentation (easiest navigated by googleing). There's also lots of tutorials and examples on how most basic things work; like the switch statement. Q1: http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html#random() \[0 \le rand() < 1 \] Q3: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html ``` switch(val) { case 1: // Code here break; case 2: // Other stuff here break; default: // Default case } ```
I think q1: int between 0 and 9 inclusive: random is between 0 and 1 exclusive multiplied by 10 and then the floor is taken (rounded down to nearest integer) q2 x && !x means x and not x so that is always false q3 see http://www.dummies.com/how-to/content/switch-statements-in-java.html shouldn't the anwer be 'default' which means 'else' indeed q5 %f see http://alvinalexander.com/programming/printf-format-cheat-sheet
3. was ELSE 4. int k = y ? x : x / 2;
Join our real-time social learning platform and learn together with your friends!