# Thread: Need help with a java assignment

1. Member
Join Date
Jan 2013
Posts
2
Rep Power
0

## Need help with a java assignment

I need help making a java program that allows the user to enter two numbers, and the program should list multiples of the first number to check if the second number is a multiple of the first. If it is, then the player gets +2 score, and if its not then the user gets -1, the user starts of the 0 score. The loop breaks when the value of the multiple exceeds 1000, and the program is supposed to ask the user to play the game as many times as they want as long as they have a POSITIVE score.

Due tommorow :|

Can anybody help me start?

That would be great! Thanks.

2. Senior Member
Join Date
Feb 2012
Posts
219
Rep Power
5

## Re: Need help with a java assignment

What code do you have so far?

3. Member
Join Date
Jan 2013
Posts
2
Rep Power
0

## Re: Need help with a java assignment

Here's what I got so far:
Java Code:
```import javax.swing.*;
class GuessMultiple{
public static void main(String str[]){
int value = 0;
double firstnumber, secondnumber;

firstnumber=Double.valueOf(input1).doubleValue();
System.out.println("First number:" +firstnumber);

secondnumber= Double.valueOf(input2).doubleValue();
System.out.println("Second number:" +secondnumber);

}
}```
I don't know how to make the first number multiply by 1, 2, 3 etc and make it check that it equals to the second number.

4. Senior Member
Join Date
Feb 2012
Posts
219
Rep Power
5

## Re: Need help with a java assignment

I think you are going about this the wrong way. How else would you determine if the second number is a multiple of the first? It doesn't require any loops or anything. It also does not need any multiplication.

6. ## Re: Need help with a java assignment

7. Member
Join Date
Dec 2012
Location
Des Moines, IA
Posts
35
Rep Power
0

## Re: Need help with a java assignment

So you got some place to start and thats a good thing. What I do is think of the assignment as a bunch of small items and not as one big item. Next work on figuring out if the number is a multiple of the other number or work on putting what you have into a simply while loop, then move on to the next.

Keep compiling and running your program everytime you have a change. This will help when you find a problem, it should be in the last bit you worked on and you don't have to search the whole thing to find whats wrong.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•