1//import classes
2import java.util.*;
3
4public class chapter5no9
5{
6 static Scanner console = new Scanner(System.in);
7
8 public static void main(String[] args)
9 {
10
11 //Part A
12 int firstNum;
13 int secondNum;
14 int sumEven;
15
16 System.out.println("Please enter an integer: ");
17 firstNum = console.nextInt();
18
19 System.out.println("Please enter another integer less than the first integer: ");
20 secondNum = console.nextInt();
21
22 //Part B
23 if (firstNum < secondNum)
24 {
25 System.out.print("Your second number is greater than the first. So Please re-enter: ");
26 secondNum = console.nextInt();
27 }
28 else
29 {
30 System.out.print("Odd Numbers: ");
31 firstNum++;
32 while (firstNum > secondNum)
33 {
34 if (secondNum % 2 != 0)
35 {
36 System.out.print(" " + secondNum);
37 }
38 secondNum++;
39 }
40
41 System.out.println();
42 System.out.print("Sum of Even Numbers: ");
43 firstNum++;
44 while (firstNum > secondNum)
45 {
46 if (secondNum % 2 != 0)
47 {
48 System.out.print(" " + secondNum);
49 }
50 secondNum++;
51 }
52 }
53}
54