1. Write a program to find the difference between two numbers?
class differnce
{
public static void main(String args[])
{
int a=10,b=5,c;
c=a-b;
[Link](c);
}
}
2. Write a program to find the area of a triangle ( Hint : area=1/2 b*h)
class AreaTriangle
{
public static void main(String args[])
{
double base=5;
double height=3;
double area = (base* height)/2;
[Link]("Area of Triangle is: " + area);
}
}
3. Write a Java program to find the volume of a sphere with its radius given as
input? Hint: Volume = 4/3*3.14*r*r*r
class volumeofasphere
{
public static void main(String args[])
{
double radius=5;
double pi=3.14;
double volume=4/3*(pi*radius*radius*radius);
[Link](volume);
}
}
4. Write a java program to calculate the compound interest for the given number
of years where rate and the basic amount are given?
r
Compound Interest = P(1 + R/100)
class comp
{
public static void main(String args[])
{
double p=1000, r=8,t=2, amount=0, ci=0;
amount= p*[Link]((1+ r/100),t);
ci=amount-p;
[Link](ci);
}
}
5. Write a java program to find simple interest? (hint : A=PRT/100)
class simplein
{
public static void main(String args[])
{
double p=1000,r=5,t=2,si=0;
si=(p*r*t)/100;
[Link](si);
}
}
6. Write a java program to find out area of cylinder? Hint:𝐴𝑟𝑒𝑎 = 2𝜋𝑟ℎ + 2𝜋𝑟 2
class cylinder
{
public static void main(String args[])
{
double r=2,h=10,A;
A = (2*3.14*r*h)+(2*3.14*r*r);
[Link](A);
}
}