Batch 28 Task-1
Batch 28 Task-1
2) Write a program to find out the area of Rectangle where length and breadth
of the Rectangle must be taken from user.
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.print("length of the rectangle -: ");
int l =sc.nextInt();
System.out.print("breath of the rectangle -: ");
int b =sc.nextInt();
System.out.println("Area of the rectangle -: "+(l*b));
}
}
3) Write a program to find the sum and average of three numbers where number
must be taken from command line argument.
4) Write a program to interchange the value of two numbers without using the
third variable where number must be taken from command line argument.
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.print("enter a number -: ");
int x=sc.nextInt();
int y=x*x*x;
System.out.println("cube of the "+x+" is "+y);
System.out.print("length -:");
x=sc.nextInt();
System.out.print("breadth -:");
y=sc.nextInt();
int z=x*y;
System.out.println("Area of the rectangle length "+x+" and breadth "+y+"
is "+z);
System.out.println("enter the two values:-");
System.out.print(" x=");
x=sc.nextInt();
System.out.print(" y=");
y=sc.nextInt();
x=x+y;
y=x-y;
x=x-y;
System.out.print(" x="+x);
System.out.println(" y="+y);
System.out.println("enter any three values-: ");
System.out.print(" x="); x=sc.nextInt();
System.out.print(" y="); y=sc.nextInt();
System.out.print(" z="); z=sc.nextInt();
z=x+y+z;
x=z/3;
System.out.println("Sum of three numbers is "+z+" and the average is
"+y);
}
}