# I need java help for beginners.

Page 1 of 1

## 2 Replies - 1670 Views - Last Post: 21 April 2007 - 11:06 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=26980&amp;s=81abcebd454d07d815d8d60a3f821ec5&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 ganni

Reputation: 1
• Posts: 8
• Joined: 21-April 07

# I need java help for beginners.

Posted 21 April 2007 - 09:51 PM

Hi. I have a problem. I am totally beginner in Java. Now I'm learning Loops. please help me!

a+b+c=15 then a, b, c=? (PS: a, b and , c are not equal each other)

a+b+c=15; then a , b and c are not equal each other. And a, b and c must be from 1 to 9. then find a=? b=? c=?
i think i should use 3 for loops. but i can't solve.
it can implement
1+5+9=15
1+6+8=15
1+8+6=15
1+9+5=15
2+4+9=15
2+5+8=15
2+6+7=15
2+8+5=15
2+9+4=15
................
...............
9+2+4=15
9+4+2=15

Help ?

Is This A Good Question/Topic? 0

## Replies To: I need java help for beginners.

### #2 vasdueva

Reputation: 15
• Posts: 141
• Joined: 03-April 07

## Re: I need java help for beginners.

Posted 21 April 2007 - 10:44 PM

all you can do is provide every possible solution. Here is a way to do it with loops. As you can see it starts with a= 0, it then enters the "b" loop with b = 0 lastly it enters the "c" loop starting with c = 0.
It will loop through for every possible combination of values. And print the ones that add up to 15.
```A=1;
while(A <= 9)
{
B = 1;
while(B <= 9)
{
C = 1;
while(C <= 9)
{
if(A + B + C == 15)
{
System.out.print ln("A:" + A + "  B:" + B + "  C:" + C);
}
C++;
}
B++;
}
A++;
}

```

This post has been edited by vasdueva: 21 April 2007 - 10:45 PM

### #3 ganni

Reputation: 1
• Posts: 8
• Joined: 21-April 07

## Re: I need java help for beginners.

Posted 21 April 2007 - 11:06 PM

vasdueva, on 21 Apr, 2007 - 10:44 PM, said:

all you can do is provide every possible solution. Here is a way to do it with loops. As you can see it starts with a= 0, it then enters the "b" loop with b = 0 lastly it enters the "c" loop starting with c = 0.
It will loop through for every possible combination of values. And print the ones that add up to 15.
```A=1;
while(A <= 9)
{
B = 1;
while(B <= 9)
{
C = 1;
while(C <= 9)
{
if(A + B + C == 15)
{
System.out.print ln("A:" + A + "  B:" + B + "  C:" + C);
}
C++;
}
B++;
}
A++;
}

```

Thank you very much! vasdueva!