You are on page 1of 5

# 1.

Write a program to find the difference between sum of the squares and the squ
are of the sums of n numbers?

public class diff
{
public static void main(String[] args)
{
diff d=new diff();
int[] a=new int[args.length];
for(int i=0;i<args.length;i++)
{
a[i]=Integer.parseInt(args[i]);
}
int sosq=0;
for(int i=0;i<args.length;i++)
{
sosq=sosq+(a[i]*a[i]);
}
System.out.println("Some of square is "+sosq);
int sqos=0;
for(int i=0;i<args.length;i++)
{
sqos=sqos+a[i];
}
sqos=sqos*sqos;
System.out.println("Some of square is "+sqos);
}
}
2. Develop a program that accepts the area of a square and will calculate its pe
rimeter.
import java.io.*;
class perimeter
{
public static void main(String[] args) throws IOException
{
System.out.println("Enter area of square");
System.out.println("Perimeter: "+(4*Math.sqrt(area)));
}
}

3. Develop the program calculateCylinderVolume., which accepts radius of a cylin
der's base disk and
its height and computes the volume of the cylinder.