That is different from what I thought.Sara Suomela wrote:. . . my method should print out all the family names that live in the building number, . . .
That looks like guessing. You can make 1,000,000 guesses and you are bound to get a correct guess somewhere. Or you can think about what the problem is and get it forst time. If you want all the names at a particular house number, your first attempt was actually closer than the second attempt.Sara Suomela wrote:. . . I tried to think in another way . . .
That's a pleasureSara Suomela wrote:First of all, thank you so much . . .
Delete lines 12‑16. You can put them back later when you have solved the first problem.When you say about using only 1 loop, do I use only this loop:
If you write down what I suggested for your line 5 in your first post, it should become clear what you are doing with the == operator. For 3 you are testing if (50 == "Holmgren") .... . . I don't get why my if-statement is wrong. Is it because I put an integer array(buildingNumber) with a string array(names)? . . .
Of course you can delete those lines. You solve lines 9‑11 and then replace lines 12‑16. Or comment out those lines by writing // at their beginning. Try ctrl‑shift‑C on your IDE. All you achieve by keeping those lines in code is having to write another method to go wrong. Sort out one thing at a time.Sara Suomela wrote:Unfortunately I cannot delete the lines 12-16 because this is given to me. . . .
Stop guessing. Start with your method reading this:-You are going to delete that statement in a few minutes. Write down how you are going to find the people at No 57, using tiny steps, as I told you earlier, and show us what you have written. If that is correct, it will give you instructions (=pseudocode) for writing your code.Any help?
I don't think you need that at all.Sara Suomela wrote:. . . I don't know how to write an if-statement between an integer array(buildingNumber) and a String array (family names).
I have question that, she had created a anonymous array and assigned to references so is it possible to read the elements of anonymous array through for loopSara Suomela wrote:. . . uildingNumbers = new int[]{57, 32, 9, 50, 31, 50, 70, 57, 50, 73};
familyNames = new String[]{"Andersson", "Johansson", "Nordin", "Holmgren", "Svensson", "Olsson", "Henriksson", "Bergner", "Loren", "Markus"};
. . .
All things are lawful, but not all things are profitable.
Don't get me started about those stupid light bulbs. |