Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do i connect two loops together?

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
my task is to build a translator using arrays, from hebrew to english, numbers 1-10.

i formed a dictionary, but the second part of the task is to validate the input of the user. the user cant put something that isnt in the dictionary, if he does , then it would give him an error...

that second part i struggle to make work, cause i dont know many ways to make one loop rely on the other




 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

This line does not do what you think it does. != cannot be used on Strings. Your logic does look correct to link the two loops.

Two comments on readability:
1) Variable names traditionally use lower case. So it would be "hebrew" and "english"
2) Are you allowed to use methods? The code would be clearer if you moved each loop to it's own method.
 
Dmitri Makovetskiy
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Jeanne Boyarsky wrote:
This line does not do what you think it does. != cannot be used on Strings. Your logic does look correct to link the two loops.

Two comments on readability:
1) Variable names traditionally use lower case. So it would be "hebrew" and "english"
2) Are you allowed to use methods? The code would be clearer if you moved each loop to it's own method.




oo h really, so how can i make it so..?

i need to change input and enough to something else
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Dmitri Makovetskiy wrote:

Jeanne Boyarsky wrote:
This line does not do what you think it does. != cannot be used on Strings. Your logic does look correct to link the two loops.

Two comments on readability:
1) Variable names traditionally use lower case. So it would be "hebrew" and "english"
2) Are you allowed to use methods? The code would be clearer if you moved each loop to it's own method.




oo h really, so how can i make it so..?

i need to change input and enough to something else



Just change the comparison to:

And as long as we're being picky Jeanne, English typically does not use apostrophes in possessive pronouns, e.g., its.

It bugs me because I do it too.
 
Bartender
Posts: 612
7
Mac OS X Python
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Yo NewOrder,

This was already solved over on daniweb yesterday
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Dmitri, you've been warned about cross posting before. BeForthrightWhenCrossPostingToOtherSites.
 
Dmitri Makovetskiy
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Rob Prime wrote:Dmitri, you've been warned about cross posting before. BeForthrightWhenCrossPostingToOtherSites.



Rob, i can see you have eyes all over the place..


whats wrong with cross posting, it hasnt been resolved , yet. i am going to check the code at daniweb
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Cross posting isn't a problem, as long as you tell us and the other party. Just click on that FAQ entry and it'll tell you why. In short, you've been wasting our times since there was already an answer and we didn't know about it.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Dmitri Makovetskiy wrote:
whats wrong with cross posting, it hasnt been resolved , yet



I don't get it. We are not saying that you can't cross post, we are simply asking that you tell us that you do (with a simple link). This is so that people can check to see if a question has been answered first.

It's just common courtesy.

Henry


PS... and since this topic has been answered...
    Bookmark Topic Watch Topic
  • New Topic