# Untitled

unknown
plain_text
a year ago
4.2 kB
37
Indexable
Never
```LAB 1A: Program to check x and y values using if statement and displaying message whether x is greater than y

package LabPgm1;

public class Pgm1
{
public static void main(String args[])
{
int x=8, y=3;

System.out.println("X = " +x);
System.out.println("Y = " +y);

if( x > y )
System.out.println("X is greater than Y");
else
System.out.println("Y is greater than X");
}

}

OUTPUT:

X = 8
Y = 3
X is greater than Y

LAB 2A: Program to list the factorial of the numbers from 1 to 10 using while loop

package LabPgm2;

public class Pgm2
{
public static void main(String[] args) {
int fact, i, j;

for(i=1;i<=10;i++)
{
System.out.print("\nFactorial of " + i + " is: ");
fact=1;
j=1;
while(j<=i)
{
fact = fact * j;
j++;
}
System.out.print(fact);
}

}

}

OUTPUT:

Factorial of 1 is: 1
Factorial of 2 is: 2
Factorial of 3 is: 6
Factorial of 4 is: 24
Factorial of 5 is: 120
Factorial of 6 is: 720
Factorial of 7 is: 5040
Factorial of 8 is: 40320
Factorial of 9 is: 362880
Factorial of 10 is: 3628800

LAB 3A: Program to find the area and circumference of the circle by accepting the radius from the user

package LabPgm3;
import java.util.*;

public class Pgm3
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);

circum = 2 * Math.PI * radius;

System.out.println("Area = " +area);
System.out.println("Circumference = " +circum);
}

}

OUTPUT:

2.6
Area = 21.237166338267002
Circumference = 16.336281798666924

package LabPgm4;

{
int a=2, b=6, res;
double c=3.5, d=5.6, res1;
{
res = a+b;
System.out.println("Addition of default Integer values" +a+ " and  " +b+ " is: " + res);
}
{
a=x;
b=y;
res = a+b;
System.out.println("Addition of Integer parameters values "+a+" and "+b+" is: "+res);
}
{
res1 = c+d;
System.out.println("\nAddition of default Float values " +c+ " and  "+d+ " is: " +res1);
}
{
c=x;
d=y;
res1 = c+d;
System.out.println("Addition of Float parameters values "+c+" and "+d+" is: " +res1);
}

}

package LabPgm4;

public class Pgm4
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);

int a,b;
double c,d;

System.out.println("Enter 2 integer values" );
a=in.nextInt();
b=in.nextInt();

System.out.println("Enter 2 float values" );
c=in.nextDouble();
d=in.nextDouble();

}

}

OUTPUT:

Enter 2 integer values
3
6
Enter 2 float values
2.3
6.5

Addition of default Integer values 2 and 6 is: 8
Addition of Integer parameters values 3 and 6 is: 9

Addition of default Float values 3.5 and 5.6 is: 9.1
Addition of Float parameters values 2.3 and 6.5 is: 8.8

LAB 5A: Program to perform arithmatic operations by extending the classes

package LabPgm5;
import java.util.*;

{
int a, b;
Scanner in = new Scanner(System.in);
void getdata()
{
System.out.println("Enter a value:");
a= in.nextInt();
System.out.println("Enter b value:");
b= in.nextInt();
}
{
}
void sub1()
{
sub = a - b;
System.out.println("Subtraction: "+sub);
}
}

package LabPgm5;
{
int mul;
double div;

void mul1()
{
mul = a * b;
System.out.println("Multiplication: "+mul);
}
void div1()
{
div = a / b;
System.out.println("Division: "+div);
}
}

package LabPgm5;
public class Pgm5
{
public static void main(String[] args)
{
MulDiv obj = new MulDiv();

obj.getdata();
obj.sub1();
obj.mul1();
obj.div1();
}

}

OUTPUT:

Enter a value:
6

Enter b value:
2