-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMultiple.java
125 lines (60 loc) · 1.85 KB
/
Multiple.java
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import java.util.Scanner; //imports
//Date: October 22 2024
//Name: multiple.java
//Description: Create an application that determines, for a pair of integers, whether the second integer is a multiple of the first.
public class Multiple{
public static void main(String[]args) {
boolean continueornott;
continueornott=true;
while (continueornott) {
int FirstInt=GetFirstInt();
int SecondInt=GetSecondInt();
boolean divisorornot=modulus(FirstInt,SecondInt);
answer(divisorornot,SecondInt,FirstInt);
continueornott=continueorNot();
}
}
private static int GetFirstInt(){
int FirstInteger;
Scanner input=new Scanner(System.in);
System.out.println("Enter the 1st integer");
FirstInteger=input.nextInt();
return FirstInteger;
}
private static int GetSecondInt(){
int SecondInteger;
Scanner input=new Scanner(System.in);
System.out.println("Enter the Second integer");
SecondInteger=input.nextInt();
return SecondInteger;
}
private static boolean modulus(int FirstInt,int SecondInt){
if (FirstInt%SecondInt==0) {
return true;
}
else {
return false;
}
}
private static void answer(boolean divisorornot,int FirstInt,int SecondInt){
if (divisorornot==true) {
System.out.printf("%d is a divisor of %d",FirstInt,SecondInt);
}
else {
System.out.println("The ints aren't divisors");
}
System.out.println("");
}
private static boolean continueorNot(){
String userwants;
Scanner input=new Scanner(System.in);
System.out.println("Do u want to continue. Enter Y if yes, enter anything else if no");
userwants=input.next();
if (userwants.equalsIgnoreCase("Y")) {
return true;
}
else {
return false;
}
}
} //main class