Java for the ladies

My wife doesn't really like coding, she can find her way around HTML, CSS en some Javascript... but only if I really don't feel like doing it for her. Can't blame her, she is a designer.

She does however like making puzzles, specifically numerical puzzles like sudoku.

While preparing for the upcoming exam I stumbled over the following question, which I asked her to try and figure out.

Place the fragments into the code to produce the output 33. Note, you MUST use each fragment exactly once

JAVA:
  1. class Incr{
  2.   public static void main(String ... args){
  3.     Integer x = 7;
  4.     int y = 2;
  5.  
  6.     x __ __ ;
  7.     __ __ __;
  8.     __ __ __;
  9.     __ __ __;
  10.     System.out.println(x);
  11.   }
  12. }

The allowed fragments:

y y y y
y x x  
-= *= *= *=

After introducing her to some basic concepts ( x *= x could be written x = x*x) she got to work, and managed to come up with the answer. Can you?


78 Responses to “Java for the ladies”

  1. 1 Frans Maas

    Piece of cake!

  2. 2 Danielle

    Yeah right, and the answer is? Did you mail that to Peter? ;)

Leave a Reply





About

Welcome to the weblog of Peter Maas. Here you'll find various posts related to stuff I like (like my kids and espresso) and stuff I do (like developing software).

JavaOne 2008 Pictures

koe golden_gate_warning_sign IMG_6130 sfeervolverlichte boot IMG_4684.JPG breun raadhuis_hilversum Danielle op de bruggen van Beeld en Geluid IMG_4705.JPG _MG_8016 starbucks zed shaw IMG_4590 kikker (frog) bridge mga dashboard Golden Gate bee on yellow flower Sjoerd op zonnig bospad Rudie
View more photos >

Categories



Meld u aan voor PayPal en begin direct met het accepteren van creditcardbetalingen.