Byron's CSC212 Web Site

CS1 at Oswego

Hypertexknowlogy

Frequently Asked Questions

 
Byron's CSC212 Web Site  
 
 
Programming Challenge Archive

Shapes World
Money
 
 

 
  JavaApplication  -- Money

   // General Information
   // ---------------------------------------------------
  
   // File:  MoneyApp.java
   // Type:  java application file
   // Date:  Wed Oct 4, 2000
   // Name:  Byron Bahr
   // Line:  Find the Uncovered Area on a Dollar
  
   // Application Description
   // ---------------------------------------------------
  
   /*
      This program calculates the area uncovered by a 
      nickel, dime, and quarter on a dollar bill 
   */
  
   // Required Packages
   // ---------------------------------------------------
  
      import blue.io.*;
      import blue.math.*;
      import blue.shapes.*;
  
   // Application Class
   // ---------------------------------------------------
  
      class MoneyApp
      {
         static public void main (String args[])
         {
         // Define the Dimensions of Money
             double dimeDiameter = 0.705;
             double nickelDiameter = 0.835;
             double quarterDiameter = 0.955;
             double dollarLength = 6.14;
             double dollarHeight = 2.61;
  
         // Model the Money
             Circle dime = new Circle (dimeDiameter/2);
             Circle nickel = 
               new Circle (nickelDiameter/2);
             Circle quarter = 
               new Circle (quarterDiameter/2);
             Rectangle dollar = new 
               Rectangle (dollarHeight,dollarLength);
  
         // Compute the Unobscured Area of the Dollar
             double unobscuredArea = 
                dollar.area() -
               (nickel.area() +
                dime.area() +
                quarter.area());
  
         // Display the Result
             IO.print ("The unobscured area is ");
             IO.print (unobscuredArea);
             IO.println (" square inches");
  
         }
      }
  
   // Demo
   // ---------------------------------------------------
  
   /*
   The unobscured area is 14.3711354833900 square inches
   */