Question

Write a java program that compute the circumference and area of a circle from the user...

Write a java program that compute the circumference and area of a circle from the user input for a radius.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Area_and_Circumofcircle.java

    import java.util.Scanner;//keyboard inputting

    public class Area_and_Circumofcircle

    {//main class

        public static void main(String[] args)

        {//main method

            int r;

            double pi = 3.14, area,circumference;

            Scanner s = new Scanner(System.in);

            System.out.print("Enter radius of circle:");

            r = s.nextInt();//keyboard inputting

            area = pi * r * r;//area of circle
            circumference=2*pi*r;//circumference of circle

            System.out.println("Area of circle:"+area);
            System.out.println("Circumference of circle"+circumference);
        }          

    }

output

Enter radius of circle:5
Area of circle:78.5
Circumference of circle31.400000000000002

Add a comment
Know the answer?
Add Answer to:
Write a java program that compute the circumference and area of a circle from the user...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that calculates the area and circumference of a circle. It should ask the...

    Write a program that calculates the area and circumference of a circle. It should ask the user first to enter the number of circles n, then reads the radius of each circle and stores it in an array. The program then finds the area and the circumference, as in the following equations, and prints them in a tabular format as shown in the sample output. Area = πr2 , Circumference = 2πr, π = 3.14159 Sample Output: Enter the number...

  • Write a Java console application that prompts the user to enter the radius of a circle,...

    Write a Java console application that prompts the user to enter the radius of a circle, then prints its radius, diameter, circumference, and area. Write a JavaFX GUI application to do the same calculation, and draw the circle. The Console Output Enter the radius of the circle: 1.2 The radius is 1.2 The diameter is 2.4 The circumference is 7.5398223686155035 The area is 4.523893421169302 Write and document your program per class coding conventions. Add an instance variable double radius. Generate...

  • Using the algorithm information below, program a calculator for the area and circumference of a circle....

    Using the algorithm information below, program a calculator for the area and circumference of a circle. Answer in C LANGUAGE !! Algorithm for Area and Circumference of a Circle: Inputs: - radius of the circle Outputs: - the area of the circle - the circumference of the circle Relevant Constants and Formulas: - area of a circle = PI x Radius x Radius - circumference of a circle = 2 x PI X Radius Main Algorithm (numbered steps) 1. Input...

  • 1. Write a program that determines the area and perimeter of a square. Your program should...

    1. Write a program that determines the area and perimeter of a square. Your program should accept the appropriate measurement of the square as input from the user and display the result to the screen. Area of Square = L (squared) Perimeter of Square = 4 * L 2.  Write a program that determines the area and circumference of a circle. Your program should accept the appropriate measurement of the circle as input from the user and display the result to...

  • Write a Perl program that computes the circumference of a circle. Your program prompts for and...

    Write a Perl program that computes the circumference of a circle. Your program prompts for and accepts a radius from the person running the program. So, if the user enters 12.5 for the radius, she should get the answer about 78.5. Circumference is 2π times the radius (approximately 2 times 3.141592654).

  • Java Write a program that prompt the user to enter a decimal number representing the radius...

    Java Write a program that prompt the user to enter a decimal number representing the radius of a circle. If the number is greater or equal to zero, the program displays the area of the circle. Otherwise, the program displays “negative input”

  • Write and test a program that computes the area of a circle. Request a number representing...

    Write and test a program that computes the area of a circle. Request a number representing a radius as input from the user. Use the formula 3.14 × radius2 to compute the area. Output this result with a suitable label.

  • Please write in JAVA ONLY Please use a dialog box to prompt the user to enter...

    Please write in JAVA ONLY Please use a dialog box to prompt the user to enter the radius for a circle (radius should be a double). Then, use a Message Box to display the Radius, Area and Circumference of the circle with that Radius. You will use the Math class constant Math.PI to calculate the Area and Circumference.

  • Write a function that prints the area and circumference of a circle for a given radius....

    Write a function that prints the area and circumference of a circle for a given radius. Only the radius is passed to the function. The function does not return any values. The area is given by π r2 and the circumference is 2 π r.

  • Write a java class definition for a circle object. The object should be capable of setting...

    Write a java class definition for a circle object. The object should be capable of setting radius, and computing its area and circumference. Use this to create two Circle objects with radius 10 and 40.5, respectively. Print their areas and circumference. Here is the Java class file (Circle.java). Compile it. public class Circle{ //Instance Variables private double PI = 3.1459; private double radius; //Methods public Circle ( ) { }    //get method (Accessor Methods ) public double getRadius (...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT