accepts the area of a square and will calculate its perimeter.

Ads

 
 
 

Share on Google+Share on Google+

NareshChowdary
accepts the area of a square and will calculate its perimeter.
1 Answer(s)      6 years and 5 months ago
Posted in : Java Beginners

Develop a program that accepts the area of a square and will calculate its perimeter.

Ads
View Answers

December 11, 2010 at 5:46 PM


Hi Friend,

Try the following code:

import java.util.*;
import java.text.*;
class  PerimeterOfSquare{
    public static void main(String[] args) 
    {
         DecimalFormat df = new DecimalFormat("##.00");
         Scanner input=new Scanner(System.in);
         System.out.println("Enter Area of Square:");
         double area=input.nextDouble();
         double side=Math.sqrt(area);
         System.out.println("Side of Square is: "+df.format(side));
         double perimeter=4*side;
         System.out.println("Perimeter of Square is: "+df.format(perimeter));

    }
}

Thanks


Ads









Related Tutorials/Questions & Answers:
accepts the area of a square and will calculate its perimeter.
accepts the area of a square and will calculate its perimeter.  Develop a program that accepts the area of a square and will calculate its perimeter... input=new Scanner(System.in); System.out.println("Enter Area of Square
Write a program to calculate area and perimeter of a circle
Write a program to calculate area and perimeter of a circle... example will teach you the method for preparing a program to calculate the area and perimeter of a circle. First of all name a class as "CircleArea"
Advertisements
How to calculate area of rectangle
How to Calculate Area of Rectangle       In this section we will learn how to calculate area... rectangle method which takes two parameters of type integer. To calculate the area
How to calculate area of triangle
; In this section we will learn how to calculate area of triangle. We... the area of triangle define the method triangle which will calculate the area... .style1 { margin-right: 0px; } How to Calculate
How to calculate area of Circle
How to Calculate Area of Circle   ... of calculating  the area of circle. In this program you will be taught each and every... the area of circle. After that it return the area of circle, return the doubles type
A Program to find area and perimeter of Rectangle
with the dot operator, invoking the method area(), which calculate the area and perimeter...A Program to find area and perimeter of Rectangle In this section we will explain you with the help of a program to find the area and perimeter of 
Write a program for calculating area and perimeter of a rectangle
Write a program for calculating area and perimeter of a rectangle... this lesson, you will be able to write program for calculating the area and perimeter.... This is an instance of class method and is used to convert a string to an integer. Define the area
java code
java code   Develop a program that accepts the area of a square and will calculate its perimeter
program
program  accepts the area of a square and will calculate its perimeter.   Hello Friend, Visit Here Thanks
Square Root
Square Root  Hi, can any one please tell me the code to findout the square root of a given number with using built in function??? Thanks a lot in advance!! Regards: Akash
Square Elements of Two Dimensional Array
the two dimensional array program and its square. This session provide you... Square Elements of Two Dimensional Array   ...: We are going to display the square of two matrix. Firstly, we have to define
Create an HTML form login.html that accepts the username and password
Create an HTML form login.html that accepts the username and password   Create an HTML form login.html that accepts the username and password and submits to login.java servlet. Verify credentials and on success, set the username
Text Area
Text Area  how to browse an image in text area instead of giving url of particular image
print square of any number
print square of any number  using c++ language, write aprogram to print the square of any number entered by the user
BlueJ (area of circle)
BlueJ (area of circle)  How does one write a program to calculate the area of a circle in BlueJ? Note that the user will have to provide the radius.   A simple program to calculate the area of a circle. radius provided
Method which returns area of circle - Java Beginners
of Circle : "+area); double perimeter = a.perimeterOfCircle(r...Method which returns area of circle  Need simple Java Method example that returns area of circle  Java Example CodeWith the help of given
MySQL Area
; Run Procedure to calculate area: You can run MySQL stored procedure by using... MySQL Area       This example illustrates how to find the area of rectangle in MySQL. In this example
square - Java Beginners
square  what is the java code to display the shape of "square"?  Hi friend, Code to display the shape of "square" import... SquareShape extends Frame { Shape square = new Rectangle2D.Double(100, 100,100
printing hollow square
printing hollow square  Write an application (PrintingSquares.java) that prompts the user to enter the size of the side of a square, then displays a hollow square of that size made of asterisks. Your program should work
calculate average
calculate average  Question 2 cont.d Test case c: home works/labs 10 9 9 9 10 10 9 9 10 10 9 9 10 test scores: 65 89 note, the program should work with different numbers of home works/labs
calculate the time ..
calculate the time ..  [CODE] Elapsed Time Example <script type="text/javascript"> var startTime = null...="button" value="Calculate Difference" onclick="calculateTimeElapsed();" />
calculate average
calculate average   Design and write a java program to determine all three digit numbers such that the sum of the cubes of the digits is equal... and write a program and calculate your final average in this course. The details
Area Tag in html5, Definition of <area> tag in HTML5.
Area Tag in html5, Definition of  <area> tag in html5 In this section we will discuss the use of <area> tag and about its implementation in the html document. The <area> tag is used for creating an area
Security in Web Service
) {   return "area of square of side"+side+" ... Develop a web service program for Square   area calculation... the web service class name as square Type the package name 
Calculate sum and Average in java
Calculate sum and Average in java  How to calculate sum and average in java program?   Example:- import java.io.BufferedReader; import.... The given code accepts the numbers from the user using BufferedReader class. Then using
area of a circle - Java Beginners
area of a circle  Write a class circle which consists of functions getdata() and area(), and also write a main program to create a circle object and to find the area by calling the function area () in circle class and display
bean area - SQL
bean area  how to print bean area in excel sheet from oracle forms
calculate reward points.
calculate reward points.  How to calculate reward points in a multiplex automation system
calculate size of array
calculate size of array  Is it possible to calculate the size of array using pointers in Java
MySQL Area
MySQL Area  This example illustrates how to find the area of rectangle in MySQL. In this example we create a procedure to find the area of rectangle. In the query below we declare two integer type variable w and h with default
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Tutorials   
Java Spring Hibernate Struts Training ClassNotFoundException HttpRequestInterceptor java.lang.noclassdeffounderror: org/apache/http/httprequest noclassdeffounderror: org/apache/http/client/methods/httpurirequest java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient How do I resolve this Java Class not found exception? httpclient java.lang.NoClassDefFoundError Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java

Ads

 
Advertisement null

Ads