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
Expected Output:
Hello World!

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
Expected Output:
Enter length : 5
Enter breadth : 4
Enter height : 3

Volume of Cuboid is : 60

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
Expected Output:
Volume of Cuboid is : 20745

Volume of Cuboid which length is 45 breadth is 23 and height is 21 is : 20745

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
Expected Output:
Enter side : 5

Area of Square : 25