Professional Documents
Culture Documents
Learn More Scribd Upload A Document Search Documents: Explore Sign Up Log in
Learn More Scribd Upload A Document Search Documents: Explore Sign Up Log in
Search Documents
/ 13
Download this Document for Free JAVA ASSIGNMENT 11. Write a program to find the difference between sum of the squares and the squareof the sums of n numbers?Program: import java.io.*;import java.util.*;class DiffSumSqu{ public static void main(String args[]) throws IOException{Scanner s=new Scanner(System.in);System.out.println("Enter the value of n: ");int n=s.nextInt();int SumSqua=((n^3)/3)+((n^2)/2)+(n/6);int sum = 0;for(int i = n;i>=0;i--){sum = sum + i;}int SquaSum = sum * sum;diff = SumSquaSquaSum;System.out.println("Difference between sum of the squares and the square of the sum of given "+n);System.out.print(" numbers is : "+diff);System.out.println("");} } Output: Enter the value of n:5Difference between sum of the squares and the square of the sum of given 5 numbers is :3328 2) Develop a program that accepts the area of a square and will calculate itsperimeter.Program: import java.io.*;import java.util.*;class AreaPeri{ public static void main(String args[]) throws IOException{Scanner s=new Scanner(System.in);System.out.println("Area of Square : ");double Area=s.nextDouble();double Perimeter=4*Math.sqrt(Area);System.out.print("so the Perimeter of the Square : "+p);System.out.println("");}} Output: Area of Square :16so the Perimeter of the Square : 16.0 3)Develop the program calculateCylinderVolume., which accepts radius of acylinder's base disk and its height and computes the volume of the cylinder.Program: import java.io.*;import java.util.*;class CalculateCylinderVolume{ public static void main(String args[]) throws IOException{Scanner s=new Scanner(System.in);System.out.println("Enter the radius : ");double rad=s.nextDouble();System.out.println("Enter the height : ");double ht=s.nextDouble();double vol=Math.PI*rad*rad*ht;System.out.println("");System.out.println("Volume of the cylinder is : " + vol);}
Java Assignment 1 Download this Document for FreePrintMobileCollectionsReport Document Info and Rating Follow
Related Documents
PreviousNext 1. p.
p.
p.
2. p.
p.
p.
3. p.
p.
p.
4. p.
p.
PreviousNext 1. 13 p.
Add a Comment
Upload a Document
Search Documents Follow Us! scribd.com/scribd twitter.com/scribd facebook.com/scribd About Press Blog Partners
Scribd 101 Web Stuff Scribd Store Support FAQ Developers / API Jobs Terms Copyright Privacy