RingArea3

RingArea3 - if(radius >= 0){ return true; } else...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
public class RingArea3{ public static void main(String args [ ]){ double radius1 = IO.readDouble( ); if (checkRadius(radius1)){ double radius2 = IO.readDouble( ); if (checkRadius(radius2)){ if (radius1 < radius2){ IO.outputDoubleAnswer(ringArea(radius2, radius1)); } else { IO.outputDoubleAnswer(ringArea(radius1, radius2)); } } } } public static boolean checkRadius(double radius){
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if(radius &gt;= 0){ return true; } else { IO.reportBadInput( ); return false; } } public static double ringArea(double outerRadius, double innerRadius){ return circleArea(outerRadius) - circleArea(innerRadius); } public static double circleArea(double radius){ double radiusSq = radius * radius; return radiusSq * Math.PI; } }...
View Full Document

This note was uploaded on 07/12/2009 for the course CS 111 taught by Professor Hari during the Fall '08 term at Rutgers.

Ask a homework question - tutors are online