1.
Write a programming in java to display any message
package firstp;
public class p1 {
public static void main(String[] args) {
System.out.println("on friday we will study oop");
2. Write a java program to give the example of operators
A. inclement and decrement operators
package operators;
public class op1 {
public static void main(String[] args) {
int number = 10;
number++;
System.out.println("After increment: " + number);
number--;
System.out.println("After decrement: " + number);
}
}
b. Bitwise Operator
package operators;
public class op2 {
public static void main(String[] args) {
int a = 5;
int b = 3;
int andResult = a & b;
System.out.println("a & b = " + andResult);
int orResult = a | b;
System.out.println("a | b = " + orResult);
c. Arithmetic operator
package operators;
public class op3 {
public static void main(String[] args) {
int a = 2;
int b = 8;
int sum = a + b;
System.out.println("Sum: " + sum);
int sub = a - b;
System.out.println("substraction: " + sub);
int product = a * b;
System.out.println("Product: " + product);
D. Relational Operator
package operators;
public class op4 {
public static void main(String[] args) {
int a = 4;
int b = 5;
System.out.println("a == b: " + (a == b));
System.out.println("a != b: " + (a != b));
3.calculate volume of cylinder if all parameter of cylinder are inputted by an
interactive user
Solution
package calvolumecylinder;
import java.util.Scanner;
public class test {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the radius of the cylinder: ");
double radius = scanner.nextDouble();
System.out.print("Enter the height of the cylinder: ");
double height = scanner.nextDouble();
double volume = Math.PI * Math.pow(radius, 2) * height;
System.out.println("The volume of the cylinder is: " + volume);
scanner.close();
}
4. write s java program to check if input integer is odd or even in eclipse
solution
package check;
import java.util.Scanner;
public class oddeven {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter an integer: ");
int number = scanner.nextInt();
if (number % 2 == 0) {
System.out.println("The number " + number + " is even.");
} else {
System.out.println("The number " + number + " is odd.");
}
scanner.close();
5. A java program to calculate product of 3 floating point if an inteeactive user Is
requested to in put those number
solution
import java.util.Scanner;
public class ProductCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter three floating-point numbers:");
float number1 = scanner.nextFloat();
float number2 = scanner.nextFloat();
float number3 = scanner.nextFloat();
float product = number1 * number2 * number3;
System.out.println("The product of the three numbers is: " + product);
scanner.close();
}
}