DEV Community

Infanta Mano
Infanta Mano

Posted on

Java

int no = 10;
if(no >15) { // true or false
System.out.println("Hi...!");
}
else if(no >5) { // true
System.out.println("else if");
}
else if(no >6) {
System.out.println("else if 2");
}
else {
System.out.println("False");
}

if(no >5) // true or false
System.out.println("Hi...!");
Nantha Kumar
10:05 AM
System.out.println("Hiii ...!");
double purchaseAmount = 7500.0;
double discount;

    if(purchaseAmount >10000) {
        discount =20;
    }
    else if (purchaseAmount>5000){
        discount = 10;
    }
    else {
        discount =5;
    }

    System.out.println("Purchase Amount: " + purchaseAmount);
    double discountAmount = (purchaseAmount * discount) /100;
    System.out.println("Discount Amount: " + discountAmount);
    System.out.println("You have to pay : " + (purchaseAmount - discountAmount));

}
Enter fullscreen mode Exit fullscreen mode

public static void main(String[] args) {

    // switch case

    int department = 2;

    switch(department) { // 2   
    case 1: // 2 == 1
        System.out.println("Welcome to HR team");
        break;
    case 2: 
        System.out.println("Welcome to finance Team");
        break;
    case 3: // 2==3
        System.out.println("welcome to unknown team");
        break;
    }

}
Enter fullscreen mode Exit fullscreen mode

static void main(String[] args) {

    // switch case

    int department = 2;

    switch(department) { // 2   
    case 1: // 2 == 1
        System.out.println("Welcome to HR team");
        break;
    case 2: 
        System.out.println("Welcome to finance Team");
        break;
    case 3: // 2==3
        System.out.println("welcome to unknown team");
        break;
    }

}
Enter fullscreen mode Exit fullscreen mode

ghp-ewse-rsopublic static void main(String[] args) {

    // switch case

    int department = 2;

    switch(department) { // 2   
    case 1: // 2 == 1
        System.out.println("Welcome to HR team");
        break;
    case 2: 
        System.out.println("Welcome to finance Team");
        break;
    case 3: // 2==3
        System.out.println("welcome to unknown team");
        break;
    }

public static void main(String[] args) {

    // switch case

    int department = 2;

    switch(department) { // 2   
    case 1: // 2 == 1
        System.out.println("Welcome to HR team");
        break;
    case 2: 
        System.out.println("Welcome to finance Team");
        break;
    case 3: // 2==3
        System.out.println("welcome to unknown team");
        break;
    }

}
Enter fullscreen mode Exit fullscreen mode

Homework
public class Main {
public static void main(String[] args) {
int number = 10;

    if (number > 0) {
        System.out.println("The number is positive.");
    } else if (number < 0) {
        System.out.println("The number is negative.");
    } else {
        System.out.println("The number is zero.");
    }
}
Enter fullscreen mode Exit fullscreen mode

}

Top comments (0)