Re: specific values in loops
From: Oscar kind (oscar_at_danwa.net)
Date: 11/29/04
- Next message: Frances Del Rio: "jsp won't compile..."
- Previous message: VisionSet: "Re: specific values in loops"
- In reply to: Danny Gopie: "specific values in loops"
- Next in thread: Danny Gopie: "Re: specific values in loops"
- Reply: Danny Gopie: "Re: specific values in loops"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Frances Del Rio: "jsp won't compile..."
- Previous message: VisionSet: "Re: specific values in loops"
- In reply to: Danny Gopie: "specific values in loops"
- Next in thread: Danny Gopie: "Re: specific values in loops"
- Reply: Danny Gopie: "Re: specific values in loops"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]