Hi,

I have written an application that identifies if the fisrt number entered is a multiple of the second number. The application also displays the multiplication table of the second number. What I am now trying to do is to identify which postion the multiple is. For example,

5 * 4 = 20. 20 is the forth multiple of 5

4 * 5 = 20. 20 is the fifth multiple of 4

I would like the app to say which position the multiple is of the second number.

Any help would be welcome thanks

So basically you enter first number 5, second 20 and you are trying to find which multiple it is? how about 20/5 = 4?

Slavi: the way I understand it, he types:

4*5=20

so, here he has:
first: 4
operator: *
second: 5
result: 20

<result> = <second>th multiple of <first>

Puk: how is this different from printing:

<result> = <first>th multiple of <second>

?

if this is not what you are doing could you please elaborate on what exactly you did already?

Yes Slavi. That is right you enter the first number 5 then second 20. The program determines and prints that 20 is a multiple of 5. It also prints the multiplication table of 5 but I also want it to say that 20 is the fourth multiple of 5.
I have done the determination of the multiple and the multiplication tables already

I have done the determination of the multiple and the multiplication tables already

Then what do you need help with? The print statement?

Ok, so in order to find out whether it is a multiple, you can use the % operator, if it returns 0 then it is. If so, just divide the second number to the first number and u'll get the number you want. if you want to get all multiples of a number , up to 10 for example, you could do this

private int multiple;

public void findMultiples(int firstNumber){
     for(int i = 1; i<11; i++){
         multiple = i*firstNumber;
         System.out.println("Multiple at position "+ i+1 +"is "+ multiple);
     }
}

Is this what you need? I am sorry but as the others I am having troubles understanding the question

Thank you Slavi. I have been able to do it! Following your instructions and example. Thank you :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.