forked from annuraagggIIIT/Problem-Solving
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinputInteger.java
More file actions
30 lines (22 loc) · 847 Bytes
/
inputInteger.java
File metadata and controls
30 lines (22 loc) · 847 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
import java.util.Scanner;
public class OddMultiples {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Prompt the user for an input integer
System.out.print("Enter an integer: ");
int input = scanner.nextInt();
// Close the scanner to prevent resource leaks
scanner.close();
int count = 0; // Counter for odd multiples
int i = 1; // Start with the first positive integer
System.out.println("The first 10 odd multiples of " + input + " are:");
while (count < 10) {
int multiple = input * i;
if (multiple % 2 != 0) {
System.out.println(multiple);
count++;
}
i++;
}
}
}