Upload files to "OOP/Java/Lab/Week1"

This commit is contained in:
Aadit Agrawal 2024-08-05 01:06:30 +05:30
parent 24683dac5a
commit 8542582101
5 changed files with 101 additions and 0 deletions

View File

@ -0,0 +1,17 @@
class Factorial
{
public static void main(String args[])
{
int a,i,product=1;
a = Integer.parseInt(args[0]);
for(i=a;i>0;i--)
{
product = product * i;
}
System.out.println("Factorial For the Number "+a+" is "+product+".");
}
}

View File

@ -0,0 +1,16 @@
class MultiplicationTable
{
public static void main(String args[])
{
int a,b,i,c;
a = Integer.parseInt(args[0]);
b = Integer.parseInt(args[1]);
for(i=1;i<=b;i++)
{
c = a*i;
System.out.println(+a+" x "+i+" = "+c);
}
}
}

View File

@ -0,0 +1,31 @@
import java.util.Scanner; // Import the Scanner class
class NumberClassify {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int i,pos=0,zero=0,neg=0;
int[] arr;
arr = new int[10];
System.out.println("Enter 10 Numbers:");
for(i=0;i<10;i++){
arr[i] = sc.nextInt();
}
for(i=0;i<10;i++){
if(arr[i] > 0){
pos++;
}else if(arr[i] < 0){
neg++;
}else{
zero++;
}
}
System.out.println("There are "+pos+" positive numbers.");
System.out.println("There are "+neg+" negative numbers.");
System.out.println("There are "+zero+" zero values.");
}
}

View File

@ -0,0 +1,24 @@
class Palindrome
{
public static void main(String args[])
{
int a,i,c,temp,rev;
a = Integer.parseInt(args[0]);
temp = a;
rev = 0;
while(temp!=0)
{
c = temp%10;
rev = rev*10 + c;
temp = temp/10;
}
if(rev == a){
System.out.println("The number is a palindrome.");
}else{
System.out.println("The number is not a palindrome.");
}
}
}

View File

@ -0,0 +1,13 @@
class Rectangle
{
public static void main(String args[])
{
int a,b,c,l;
l = Integer.parseInt(args[0]);
b = Integer.parseInt(args[1]);
c = 2*(l+b);
a = l*b;
System.out.println("The Circumference of the Rectangle = "+ c);
System.out.println("The Area of the Rectangle = "+ a);
}
}