diff --git a/OOP/Java/Lab/Week1/Factorial.java b/OOP/Java/Lab/Week1/Factorial.java new file mode 100644 index 0000000..c3db044 --- /dev/null +++ b/OOP/Java/Lab/Week1/Factorial.java @@ -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+"."); + + } +} \ No newline at end of file diff --git a/OOP/Java/Lab/Week1/MultiplicationTable.java b/OOP/Java/Lab/Week1/MultiplicationTable.java new file mode 100644 index 0000000..4463502 --- /dev/null +++ b/OOP/Java/Lab/Week1/MultiplicationTable.java @@ -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); + } + } +} \ No newline at end of file diff --git a/OOP/Java/Lab/Week1/NumberClassify.java b/OOP/Java/Lab/Week1/NumberClassify.java new file mode 100644 index 0000000..a0e57fb --- /dev/null +++ b/OOP/Java/Lab/Week1/NumberClassify.java @@ -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."); + + } +} \ No newline at end of file diff --git a/OOP/Java/Lab/Week1/Palindrome.java b/OOP/Java/Lab/Week1/Palindrome.java new file mode 100644 index 0000000..c253376 --- /dev/null +++ b/OOP/Java/Lab/Week1/Palindrome.java @@ -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."); + } + } +} \ No newline at end of file diff --git a/OOP/Java/Lab/Week1/Rectangle.java b/OOP/Java/Lab/Week1/Rectangle.java new file mode 100644 index 0000000..71df307 --- /dev/null +++ b/OOP/Java/Lab/Week1/Rectangle.java @@ -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); + } +} \ No newline at end of file