-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP9.java
More file actions
26 lines (23 loc) · 770 Bytes
/
P9.java
File metadata and controls
26 lines (23 loc) · 770 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
package com.tka.demo2;
import java.util.Scanner;
public class P9 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter start number: ");
int start = sc.nextInt();
System.out.print("Enter end number: ");
int end = sc.nextInt();
for (int i = start; i <= end; i++) {
if (i % 3 == 0 && i % 5 == 0) {
System.out.println("Mango and Apple");
} else if (i % 3 == 0) {
System.out.println("Mango");
} else if (i % 5 == 0) {
System.out.println("Apple");
} else {
System.out.println(i);
}
}
sc.close();
}
}