import java.awt.Color; import java.text.DecimalFormat; import uwcse.graphics.Oval; public class Arithmetic { /** * Write a method that takes an Oval (which is a circle) * and returns its area */ public double ovalArea(Oval o) { int radius = o.getHeight()/2; double area = Math.PI * radius * radius; return area; // double area = Math.PI * Math.pow(radius, 2); /* * To compute a power * Math.pow(x,y) computes x to the yth power */ } public static void main(String[] args) { Arithmetic a = new Arithmetic(); Oval o = new Oval(10, 10, 50, 50, Color.BLUE, true); double area = a.ovalArea(o); System.out.println(area); // or to print to 2 decimal places // use the DecimalFormat class // (in the java.text package) DecimalFormat df = new DecimalFormat("0.00"); System.out.println(df.format(area)); // throw of a die // Generate a random int = 1,2,3,4,5 or 6 int val = (int)(6 * Math.random()) + 1; } }