0% found this document useful (0 votes)
6 views2 pages

Java Programs: Basics and Examples

The document contains multiple Java classes, each with a main method demonstrating different functionalities. These include printing 'Hello World', performing basic arithmetic operations in a Calculator, calculating simple interest, generating Fibonacci numbers, displaying multiplication tables, and computing the factorial of a number. Each class serves as a standalone program showcasing fundamental programming concepts in Java.

Uploaded by

Shruti Vikas
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Java Programs: Basics and Examples

The document contains multiple Java classes, each with a main method demonstrating different functionalities. These include printing 'Hello World', performing basic arithmetic operations in a Calculator, calculating simple interest, generating Fibonacci numbers, displaying multiplication tables, and computing the factorial of a number. Each class serves as a standalone program showcasing fundamental programming concepts in Java.

Uploaded by

Shruti Vikas
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

class FirstProgram

{
public static void main(String arg[])
{
[Link]("Hello World");
}
}

class Calculator
{
public static void main(String arg[])
{
double b=12.0d;
double a=5.0d;
[Link]("Addition:"+ (a+b));
[Link]("subtraction:"+ (a-b));
[Link]("multiplication:"+ (a*b));
[Link]("division:"+ (b/a));
}
}

class SimpleInterest
{
public static void main(String arg[])
{
double principle=12000.0d;
double rate=5.0d;
double time=3.0d;
[Link]("Simple intrest amount
is:"+((principle*rate*time)/100));

}
}

class Fibonacci
{
public static void main(String arg[])
{
int a=0;
int b=1;
for(int i=0;i<10;i++){
int c=a+b;
[Link](a);
a=b;
b=c;}
}
}

class MultiplicationTables
{
public static void main(String arg[])
{
int a=3;
int b=5;
[Link]("3 Tables:");

for(int i=1;i<11;i++){
int c=3*i;
[Link](a + "X" + i + "=" + c);
}
[Link]("5 Tables:");
for(int j=1;j<11;j++){
int d=5*j;
[Link](b + "X" + j + "=" + d);
}

class Factorial
{
public static void main(String arg[])
{
int j=7;
int k=1;
for(int i=j;i>1;i--){
k=k*i;

}
[Link]("The factorial of 7 is:"+k);
}

You might also like