Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help with class assignment  RSS feed

 
Felicia Brown
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, I'm new to Java and I need help writing a method multiple that determines, for a pair of integers, whether the second integer is a multiple of the first and false otherwise. [use the remainder operator]. Incorporate this method into an application that inputs a series of pairs of integers (one pair at a time) and determines whether the second value in each pair is a multiple of the first.

Here' what I have so far:

public class Multiplicity
{
// checks if the second number is a multiple of the first
public void checkMultiples()
{
//Enter first number or 0 to exit);

// use 0 as the sentinel value, since we cannot divide by zero
while ( first != 0 )
{
//Enter second number;

Call procedure multiple( first, second )

//Enter next round of first number;

} // end while loop
} // end method checkMultiples

// determine if first int is a multiple of the second
public boolean multiple( int firstNumber, int secondNumber )
{
return secondNumber % firstNumber == 0;
} // end method multiple
} // end class Multiplicity
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

What part exactly are you stuck on?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!