Hey guys,
This is my answer to a homework problem and i have the program working but i want to make sure you agree that it meets the functionality because its worded funky.
Any input is apprciaited
Problem: Write a method named multiple that determines, for a pair of integers, whether the second integer is a multiple of the first. The method should take two integer arguments and return true if the second is a multiple of the first and false otherwise. [Hint: Use the remainder operator.] The main () method in the test driver should read two integers, call multiple to determine if one is a multiple of the other, and print a message – i.e. as in:
The number 4 is a multiple of the number 2
or
The number 5 is not a multiple of 2
There is no need to create two classes – simply the test driver.
import java.util.Scanner; //Allows me get values from users. public class multiples { public static void main(String[] args) { //Initializes Scanner for use Scanner input=new Scanner(System.in); //Declaring the Variables I will use. int FirstNumber; int SecondNumber; boolean isamultiple; System.out.println("Please Enter First Integer: \n"); FirstNumber = input.nextInt(); System.out.println("\nPlease Enter Second Interger: \n"); SecondNumber=input.nextInt(); isamultiple=testmultiple(FirstNumber,SecondNumber); if (isamultiple) System.out.printf("\nThe number %s is a multiple of the number %s",FirstNumber, SecondNumber); else System.out.printf("\nThe Number %s is not a multiple of the number %s", FirstNumber,SecondNumber); System.exit(0); } public static boolean testmultiple(int Number1, int Number2) { if (Number1%Number2 == 0) return true; else return false;