Back to Examples
package edu.iuk.circle;

import java.util.Scanner;
import javax.swing.JOptionPane;

public class Circle {

  public static void main(String[] args) {

    //Jacob Morris
    //declare the variables
    double radius;
    double diameter;
    double area;

    //build scanner
    Scanner radi= new Scanner(System.in);
    System.out.println(“Please enter the radius of the circle. (digits only)”);

    //receives the user’s radius input
    radius = radi.nextDouble();

    //finds diameter
    diameter = radius * 2;

    //finds radius
    area = (3.14159 * radius * radius);

    //display information to the user.
    JOptionPane.showMessageDialog(null, “The diameter of the circle is ” + diameter + “.\n\nThe area of the circle is ” + area);

  }

}
Back to Examples

Startup Discount
Small Business?
Contact us for an Enormous Discount!