WhiteArea.java
1    /* 
2    Program to compute the white area of a die. 
3     */
4    
5    package shapes;
6    
7    import java.util.Scanner;
8    
9    public class WhiteArea {
10   
11       public static void main(String[] args) {
12   
13           //Given measurements
14           double EdgeLength = .75;
15           double DotRadius = ((EdgeLength / 8) / 2);
16   
17           //Creating objects
18           SSquare die = new SSquare (EdgeLength);
19           SCircle dot = new SCircle (DotRadius);
20   
21           //Calculate area of objects
22           double DieArea = die.area();
23           double DotArea = dot.area();
24   
25           //Collect user input
26           Scanner input = new Scanner(System.in);
27           System.out.print("How many dots are on the side? ");
28           int NumberOfDots = input.nextInt();
29   
30           //Calculate total dot area
31           double TotalDotArea = (DotArea * NumberOfDots);
32   
33           //Calculate and display total white area
34           double TotalWhiteArea = (DieArea - TotalDotArea);
35           System.out.println("Total white area of die with " + NumberOfDots + " black dots --> " + TotalWhiteArea + " square inches");
36       }
37   }
38