0% found this document useful (0 votes)
2 views

Practical3.1Java

The document provides a Java program that demonstrates the use of if statements with logical conditions. It checks if a number is within a specific range, if it is divisible by 2 or 3, and if it is not equal to 25, printing '1' or '0' based on the conditions. The program utilizes the Scanner class for user input and showcases multiple forms of if statements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Practical3.1Java

The document provides a Java program that demonstrates the use of if statements with logical conditions. It checks if a number is within a specific range, if it is divisible by 2 or 3, and if it is not equal to 25, printing '1' or '0' based on the conditions. The program utilizes the Scanner class for user input and showcases multiple forms of if statements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Practical- No: 3

Write programs to demonstrate use of: if statements (all forms

of if statement Switch – Case statement Different & Loops)

1. Write a program to check multiple conditions using if statement along with logical

Code:
import java.util.Scanner;

class Logi

public static void main(String args[])

Scanner scanner = new Scanner(System.in);

System.out.print("Enter a number: ");

int num = scanner.nextInt();

if (num > 10 && num < 50) {

System.out.println("1");

} else {

System.out.println("0");

if (num % 2 == 0 || num % 3 == 0) {

System.out.println("1");

} else {

System.out.println("0");

if (!(num == 25)) {

System.out.println("1");

} else {

System.out.println("0");
}

Output:

You might also like