//
// This program sets up a demonstration of procedural abstraction.
// If the program gets much bigger it will be hard to understand!
//
import java.util.*;
public class NoProceduralAbstraction
{ 
  public static Scanner input = new Scanner(System.in);
  
  public static void main(String[] args)
  {
    int yORn=1;
    do
    { 
      double years=0;
      
      // Clear the screen.
      for (int i=0; i<24; i++) 
      {
        System.out.println();
      }
      
      // Get choice... 1 for months, 2 for days 
      int choice=0;
      do 
      {
        System.out.println("Age in (1) months or (2) days: ");
        choice = input.nextInt();
      } while ((choice != 1) && (choice != 2));
      
      
      // Compute age in years given months
      if (choice == 1) 
      { 
        int age;
        int i=42;
        
        System.out.println("Enter months: ");
        age = input.nextInt();
        
        years = (age / 12.0);
      }
      
      // Compute age in years given days
      else 
      {
        int age;
        
        System.out.println("Enter days: ");
        age = input.nextInt();
        
        years = (age / 365.0);
      }
      
      
      // Output results
      System.out.println("Age in years is: " + Math.ceil(years));
      
      // Should we continue?
      System.out.println("Continue? (1=y/0=n): ");
      yORn = input.nextInt();
      
    } while (yORn == 1);
    
    
    // Clear the screen.
    for (int i=0; i<24; i++) 
    {
      System.out.println();
    }
    
  }
}
