-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMultiple.java
More file actions
32 lines (21 loc) · 758 Bytes
/
Copy pathMultiple.java
File metadata and controls
32 lines (21 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
2.26 (Multiples) Write an application that reads two integers, determines whether the first is a
multiple of the second and prints the result. [Hint: Use the remainder operator.]
*/
package chapter2;
import java.util.Scanner;
public class Multiple{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int firstNumber;
int secondNumber;
System.out.print("Enter a number: ");
firstNumber = input.nextInt();
System.out.print("Enter another number: ");
secondNumber = input.nextInt();
if(firstNumber % secondNumber == 0)
System.out.print("secondNumber is a multiple of firstNumber");
if(secondNumber % firstNumber == 0)
System.out.print("firstNumber is a multiple of secondNumber");
}
}