Re: specific values in loops

From: Oscar kind (oscar_at_danwa.net)
Date: 11/29/04


Date: Mon, 29 Nov 2004 22:09:23 +0100

Danny Gopie <ouygiytf@jhgvkuy.nl> wrote:
> I want to print only the values in this loop that are smaller then the give
> value "aantal"
>
> Now it just print true, becoz System.out.println(a < aantal); is a boolean.
> But how do i change this?
>
>
> public class e211 {
> public static void main(String[] args) {
>
> String saantal = JOptionPane.showInputDialog(null,"Voer een getal
> in","invoer getal",JOptionPane.QUESTION_MESSAGE);
> int aantal = Integer.parseInt(saantal);
>
> for ( int i = 0; i < 10; i++) {
> int a = i * aantal;
> if (a < aantal){
> System.out.println(a < aantal);}
> }
> }}

Which values do you want to print? I see three values: i, a and aantal.

You can change the output by using a different expression than
(a < aantal). Or did you mean (a + " < " + aantal)?

-- 
Oscar Kind                                    http://home.hccnet.nl/okind/
Software Developer                    for contact information, see website
PGP Key fingerprint:    91F3 6C72 F465 5E98 C246  61D9 2C32 8E24 097B B4E2