Day 1 - 15 August, 2024
Program 1: WAP to print a message
class P1 {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
Copy Code
Program 2: To find the volume of a cuboid with user input of l, b, and h
import java.util.*;
class P2 {
public static void main(String[] args) {
int l, b, h, v;
Scanner sc = new Scanner(System.in);
System.out.print("Enter length : ");
l = sc.nextInt();
System.out.print("Enter breadth : ");
b = sc.nextInt();
System.out.print("Enter height : ");
h = sc.nextInt();
v = l * b * h;
System.out.print("Volume of Cuboid is : " + v);
}
}
Copy Code
Program 3: WAP to find the volume of a cuboid without user input
class P3 {
public static void main(String[] args) {
int l, b, h, v;
l = 45;
b = 23;
h = 21;
v = l * b * h;
System.out.println("Volume of Cuboid is : " + v);
System.out.print(
"Volume of Cuboid which length is " + l + " breadth is " + b + " and height is " + h + " is : " + v);
}
}
Copy Code
Program 4: WAP to find the area of a square
import java.util.*;
class P4 {
public static void main(String[] args) {
int s, a;
Scanner sc = new Scanner(System.in);
System.out.print("Enter side : ");
s = sc.nextInt();
a = s * s;
System.out.println("Area of Square : " + a);
}
}
Copy Code