Last active
December 27, 2015 00:29
-
-
Save LordNairu/7238290 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package qub.ac.uk.practical.week5; | |
// importing scanner | |
import java.util.Scanner; | |
public class PracticalQuestionThree { | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) { | |
// Declaring scanner | |
Scanner scanner = new Scanner(System.in); | |
// Declaring variables | |
int num1; | |
int num2; | |
System.out.println("Please input two integers. To check if the second is a multiple of the first."); | |
System.out.println("Input first integer: "); | |
num1 = scanner.nextInt(); | |
System.out.println("Input second integer: "); | |
num2 = scanner.nextInt(); | |
isMultiple(num1, num2); | |
scanner.close(); | |
} | |
/** | |
* Method for comparing multiples | |
*/ | |
public static int isMultiple (int num1, int num2){ | |
if (num2 % num1 == 0){ | |
System.out.printf("Yes! %d is a multiple of %d.",num2,num1); | |
} else System.out.printf("No! %d is not a multiple of %d.",num2,num1); | |
return num1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment