EXP 3 java
EXP 3 java
EXP 3
1. Write a program to check multiple conditions using if statement along with logical operators.
import java.util.Scanner;
if (num % 2 == 0) {
System.out.println(num + " is Even.");
} else {
System.out.println(num + " is Odd.");
}
}
}
Aashay Kulkarni 183 SYCO c
import java.util.Scanner;
switch (ch) {
case 'A':
System.out.println("You selected A.");
break;
case 'B':
System.out.println("You selected B.");
break;
case 'C':
System.out.println("You selected C.");
break;
default:
System.out.println("Invalid choice.");
}
}
}
Aashay Kulkarni 183 SYCO c
4. Write a program to display 1 to 20 numbers using for, while and do-while loop.
int j = 1;
j++;
int k = 1;
do {
k++;
}
Aashay Kulkarni 183 SYCO c
import java.util.Scanner;
int number;
do {
number = sc.nextInt();