Conditional Programs

 WAP to find the greatest among two numbers.
```import java.util.Scanner;
class Test {
public static void main(String[] a)
{
Scanner s=new Scanner(System.in);
System.out.print("Enter X: ");
int x = s.nextInt();
System.out.print("Enter Y: ");
int y = s.nextInt();
if(x>y) {
System.out.print("X is Greater");
}
else {
System.out.print("Y is Greater");
}
}
}```
OUTPUT :
```Enter X: 15
Enter Y: 20
Y is Greater```
 WAP to find greatest among three numbers.
```import java.util.Scanner;
class Test {
public static void main(String[] a)
{
Scanner s=new Scanner(System.in);
System.out.print("Enter X: ");
int x = s.nextInt();
System.out.print("Enter Y: ");
int y = s.nextInt();
System.out.print("Enter Z: ");
int z = s.nextInt();
if(x>y && x>z) {
System.out.print("X is Greater");
}
else if(y>z) {
System.out.print("Y is Greater");
}
else {
System.out.print("Z is Greater");
}
}
}```
OUTPUT :
```Enter X: 15
Enter Y: 18
Enter Z: 12
Y is Greater ```
 WAP to find greatest among three numbers using nested if else.
```import java.util.Scanner;
class Test {
public static void main(String[] a)
{
Scanner s=new Scanner(System.in);
System.out.print("Enter X: ");
int x = s.nextInt();
System.out.print("Enter Y: ");
int y = s.nextInt();
System.out.print("Enter Z: ");
int z = s.nextInt();
if(x>y) {
if(x>z) {
System.out.print("X is Greater");
}
else {
System.out.print("Z is Greater");
}
}
else {
if(y>z) {
System.out.print("Y is Greater");
}
else {
System.out.print("Z is Greater");
}
}
}
} ```
OUTPUT :
```Enter X: 10
Enter Y: 18
Enter Z: 14
Y is Greater ```

 WAP to check a given number is even or odd.
```import java.util.Scanner;
class Test {
public static void main(String[] a)
{
Scanner s=new Scanner(System.in);
System.out.print("Enter a Num.: ");
int x = s.nextInt();
if(x%2==0){
System.out.print(x+" IS AN EVEN");
}
else {
System.out.print(x+" IS AN ODD");
}
}
}  ```
OUTPUT :
```Enter a Num.: 20
20 IS AN EVEN  ```
 WAP to check the alphabet is vowel or not.
```import java.util.Scanner;
class Test {
public static void main(String[] a) throws Exception
{
Scanner s=new Scanner(System.in);
System.out.print("Enter a Character: ");
if(x=='a' ||x=='e' ||x=='i' ||x=='o' ||x=='u') {
System.out.print("Character is vowel");
}
else if(x=='A' ||x=='E' ||x=='I'||x=='O' ||x=='U') {
System.out.print("Character is vowel");
}
else {
System.out.print("Character is NOT vowel");
}
}
}```
OUTPUT :
```Enter a Character: A
Character is vowel```
 WAP to ask user to enter marks of 5 subjects and calculate the percentage then print GRADE according to marks in percentage.
```import java.util.Scanner;
class Test {
public static void main(String[] a)
{
Scanner s=new Scanner(System.in);
System.out.print("Enter Marks1: ");
int m1 = s.nextInt();
System.out.print("Enter Marks2: ");
int m2 = s.nextInt();
System.out.print("Enter Marks3: ");
int m3 = s.nextInt();
System.out.print("Enter Marks4: ");
int m4 = s.nextInt();
System.out.print("Enter Marks5: ");
int m5 = s.nextInt();
double per =(m1+m2+m3+m4+m5)/5.0;
System.out.println("Percentage = "+per);
if(per>=80){
}
else if(per>=70) {
}
else if(per>=60) {
}
else if(per>=50) {
}
else {
}
}
}```
OUTPUT :
```Enter Marks1: 67
Enter Marks2: 78
Enter Marks3: 98
Enter Marks4: 67
Enter Marks5: 78
Percentage = 77.6
 WAP to print DAY according to user input for day count.
```import java.util.Scanner;
class Test {
public static void main(String[] a)
{
Scanner s=new Scanner(System.in);
System.out.print("Enter Day Number: ");
int x = s.nextInt();
switch(x) {
case 1:
System.out.print("DAY IS MONDAY");
break;
case 2:
System.out.print("DAY IS TUESDAY");
break;
case 3:
System.out.print("DAY IS WEDNESDAY");
break;
case 4:
System.out.print("DAY IS THURSDAY");
break;
case 5:
System.out.print("DAY IS FRIDAY");
break;
case 6:
System.out.print("DAY IS SATURDAY");
break;
case 7:
System.out.print("DAY IS SUNDAY");
break;
default:
System.out.print("Wrong Choice");
}
}
}```
OUTPUT :
```EEnter Day Number 4
DAY IS THURSDAY```

#### CONTACT DETAILS

info@prowessapps.in
(8AM to 10PM):

+91-8527238801 , +91-9451396824