/* Simple Program In java to Print the Following Pyramid
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
7 7 7 7 7 7 7
8 8 8 8 8 8 8 8
9 9 9 9 9 9 9 9 9
*/

class PyramidNos
{
public static void main(String args[])
{
int i,j;
System.out.println("Displaying Numbers:");
for(i=1;i< 10;i++)
{
for(j=1;j< i+1;j++)
{
System.out.print(" " +i);
}
System.out.println();
}
}
}

/* OUTPUT *

1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
7 7 7 7 7 7 7
8 8 8 8 8 8 8 8
9 9 9 9 9 9 9 9 9
*/

/********** Factorial Of A Number Based on Java ********/

class Factorial
{
public static void main(String args[])
{
int a = 5;
int fact = a;
for(int i=a-1;i>=1;i--)
fact = fact * i;
System.out.println("Factorial : "+ fact);
}
}

/********** OUTPUT ***********
Factorial : 120 */

/********** Program To Print Reverse Of A Number *******/

class Reverse
{
public static void main(String args[])
{
int i,s=0,a = 120;
int no[] = new int[10];
System.out.print("Original Number : "+a);
for(i=0;i<10;i++)
{
if(a!=0)
{
no[i] = a%10;
a = a / 10;
s++;
}
else
break;
}
System.out.print("\n\nReversed Number : ");
for(i=s;i>0;i--)
{
System.out.print(+ no[i] +" ");
}
}
}

/************ OUTPUT ************
* Original Number : 120

* Reversed Number : 0 1 2 */

/****** Implementation of Matrix Operation Using Arrays In Java *****/

class Matrix
{
public static void main(String args[])
{
int i,j,k;
int mat1 [][]={ {10,11,12}, {13,14,15}, {16,17,18} };
int mat2 [][]={ {1,2,3}, {4,5,6}, {7,8,9} };
System.out.println("Operation ON Matrices \n1.Addition \n");
int sum [][] = new int [3][3];
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
sum[i][j] = mat1[i][j] + mat2[i][j];
System.out.print("\t" + sum[i][j]);
}
System.out.println("\t");
}

System.out.println("2.Subtraction\n");
int diff[][] = new int[3][3];
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
diff [i][j] = mat1[i][j] - mat2[i][j];
System.out.print("\t"+ diff[i][j]);
}
System.out.println("\t");
}

System.out.println("3.Multiplication\n");
int prod[][] = new int[3][3];
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
prod[i][j] = 0;
{
for(k=0;k<3;k++)
prod[i][j] = prod[i][j]+mat1[i][k]*mat2[k][j];
}
System.out.print("\t"+ prod[i][j]);
}
System.out.println("\t");

}
}
}

/************* OUTPUT ***************

Operation ON Matrices
1.Addition

11 13 15
17 19 21
23 25 27
2.Subtraction

9 9 9
9 9 9
9 9 9
3.Multiplication

138 171 204
174 216 258
210 261 312 */

/* Simple Java Program that uses Command line arguments as input */

class ComandLine
{
public static void main(String args[])
{
int count, i = 0;
String string;
count = args.length;
System.out.println("Number Of Arguments : "+count);
while(i< count)
{
string = args[i];
i = i + 1;
System.out.println(i+ " : "+"Java Is "+string+ "!");
}
}
}

/* *Compile and run the command line as follows *Java Commandline Simple Object_Oriented Distributed Robust Secure Portable Multithread Dynamic */

/*** OUTPUT ***
As Seen on Java E:\Java\bin>javac Commandline.java

E:\Java\bin>java ComandLine Simple Object_Oriented Disrtibuted Robust Secure por
table Multithread dynamic
Number Of Arguments : 8
1 : Java Is Simple!
2 : Java Is Object_Oriented!
3 : Java Is Disrtibuted!
4 : Java Is Robust!
5 : Java Is Secure!
6 : Java Is portable!
7 : Java Is Multithread!
8 : Java Is dynamic!

*/

/* Simple Java Program For Claculating Area Of A Rectangle Using two Classes */

class TwoClasses
{
float length, breadth;

void getdata(float a, float b)
{
length = a;
breadth = b;
}
}

class Area
{
public static void main(String args[])
{
float area;
TwoClasses Rectangle = new TwoClasses(); // Object Reactangle
Rectangle.getdata(25,35);
area = Rectangle.length * Rectangle.breadth;
System.out.println("Area : "+area);
}
}

/* Output *
*Area : 875
*/

/*The Given Program Calculates the Following :
*1. Square root
*2. POwer of a number
*3. Sine Value
*4. Cosine Value
*5. Logarithm Value
*6. Absolute value
*
*
/* Simple Java Program For Various Mathematical Operation */

import java.lang.Math;
class MathFunctions
{
public static void main(System args[])
{
double x = 7;
double y;
System.out.println("Given Number "+x);

y = Math.sqrt(x);
System.out.println("Square Root : "+y);

y = Math.pow(x,3);
System.out.println("Power : "+y);

y = Math.sin(x);
System.out.println("Sine : "+y);

y = Math.cos(x);
System.out.println("Cosine : "+y);

y = Math.log(x);
System.out.println("Logrithm : "+y);

y = Math.abs(x);
System.out.println("Absolute Value : "+y);
}
}

Given Number 7.0
Square Root : 2.6457513110645907
Power : 343.0
Sine : 0.6569865987187891
Cosine : 0.7539022543433046
Logrithm : 1.9459101490553132
Absolute Value : 7.0
*/

/* Simple Program In Java To print on the screen */
class Simple
{
public static void main(String args[])
{
System.out.println("Java Is Better Than C and C++");
}
}

/* Output *
Java Is Better Than C and C++
*/