Question: BlueJ (area of circle)

Ads

 
 
 

Share on Google+Share on Google+

Al Russrum
BlueJ (area of circle)
3 Answer(s)      6 years and a month ago
Posted in : Java Beginners

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.

Ads
View Answers

April 7, 2011 at 12:41 AM


A simple program to calculate the area of a circle. radius provided by user.

this is what i got but i can't compile it without an error. please help if you identify my mistake.

public class stage1 { // BEGIN Area of Circle

/**
 *    Get radius from user
 *    Set area = Math.Pi * radius * radius
 *    Output "Area : " area
 * END Area of Circle
 */

public static void main(String [] areaCircle) 
{
    Scanner keyboard = new Scanner(System.in);
    System.out.println("Enterh the circle's radius: ");
    double radius = keyboard.nextDouble();
    System.out.println("int Area");
}

}



April 7, 2011 at 10:28 AM


import java.util.Scanner;
public class AreaOfCircle { 

public static void main(String [] str) 
{
    Scanner keyboard = new Scanner(System.in);
    System.out.println("Enter the circle's radius: ");
    double radius = keyboard.nextDouble();
    double PI=3.14;
    double area=PI*radius*radius;
    System.out.println("Area of circle: "+area);
    }
}


July 27, 2013 at 12:01 AM


import javax.swing.JOptionPane;
public class constant
{
public static void main(String[]args)
{

 final double PI = 3.142;
 double R1,R2,area,average;
 String input;

 input= JOptionPane.showInputDialog("AREA");
 area=Integer.parseInt(input);

 input= JOptionPane.showInputDialog("Radius 1");
 R1=Integer.parseInt(input);

 input= JOptionPane.showInputDialog("Radius 2");
 R2=Integer.parseInt(input);

 average=(area=PI*R1*R2);

 JOptionPane.showMessageDialog(null,"Area of circle: "+ area);
 System.exit(0);

Ads









Related Tutorials/Questions & Answers:
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
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
Advertisements
Method which returns area of circle - Java Beginners
Java code you can return the area of a circle and give the radius... of Circle : "+area); double perimeter = a.perimeterOfCircle(r...Method which returns area of circle  Need simple Java Method example
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
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"
circle
circle  Program to test whether a given point lies inside a circle... of the circle : "); double r = input.nextDouble... of circle : "); double x1 = input.nextDouble(); System.out.print
Creating circle inside a circle
Creating circle inside a circle  hi can any one give code for following output by awt/swing creating circle inside a circle ,outside cirlce and intersect a circle
Java Circle to Circle collision detection
Java Circle to Circle collision detection  Java Circle to Circle collision detection
Circle question - Java Beginners
void calculate(Circle c){ double r=c.getRadius(); double area=pi*r*r; double...Circle question  Hey You helped me with one this question already... that uses Circle class you created in the previous assignment. ? The program
Design a class named BankAccount to hold datas for a bank account in Java using Bluej Software - Java Interview Questions
Design a class named BankAccount to hold datas for a bank account in Java using Bluej Software  1)Design a class named BankAccount to hold the following data for a bank account: - Balance - Number of deposits
How to draw a circle bucket, draw a circle bucket, circle bucket
How to draw a circle bucket       This example has a simple way to learn easily to make a circle shape... style: Go to Layer menu > Layer style > Bevel and emboss. Draw Circle
setting RGB for a circle
setting RGB for a circle  how can i change the color of the circle(not through filling it) and i want to use RGB (not regular colors such as black or red..) i should include RGB numbers (for example 240, 150, 19) but i am
How do I handle the reaction of a circle and a semi-circle colliding in java?
How do I handle the reaction of a circle and a semi-circle colliding in java?  How do I handle the reaction of a circle and a semi-circle colliding in java
By using Applet display a circle in a rectangle
By using Applet display a circle in a rectangle  Write a java applet to display a circle in a rectangle
Text Area
Text Area  how to browse an image in text area instead of giving url of particular image
How to design a circle logo, design a circle logo, a circle logo
How to design a circle logo     ... will learn here a simple circle logo, I have not used tough steps so it is easy... a "Circle thin frame" by the Custom shape tool (U key) with any
Java GUI code- creating a circle
that prompts the user to enter the center and a point on the circle, which is (x,y)(x2,y2). The program should then output the circle's radius, circumference, and area. I did my code but I can't seem to figure out the mathematical code
How to Create Circle In Java
How to Create Circle In Java     ..., you will learn how to create Circle Diagram. The java circle is the most... the shape to enclose an area. The Java2D API  also provides several classes
Area Tag in html5, Definition of <area> tag in HTML5.
Area Tag in html5, Definition of  <area> tag in html5... in the html document. The <area> tag is used for creating an area...: The syntax for the <area> tag is as follows: <area
Java gui program for drawing rectangle and circle
gui program for drawing rectangle and circle? there shoud be circle.... and the program must also show message dialog "this is a red circle" when click circle button and red button. and same goes to "this is a red rectangle
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 take
bean area - SQL
bean area  how to print bean area in excel sheet from oracle forms
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
Flex Circle drawing example
Flex circle drawing example   ... and the button operator. The circle is not a default feature, the instructions for drawing a circle is defined inside the Sprite class of flash.display
Area Chart
Area Chart       In this section we are providing you an example to create a Area Chart. Description of Program For creating a Area Chart we use the object
How to calculate area of triangle
Area of Triangle       In this section we will learn how to calculate area of triangle. We are going to use area of triangle is half of the area of the parallelogram. Here
Tutorials   
Java Spring Hibernate Struts Training 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 Java Example Codes and Tutorials in 2017 How do I read a large file quickly in Java? Is learning Java worthwhile? How to create first Java Program? Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include?

Ads

 
Advertisement null

Ads