home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 14 / IOPROG_14.ISO / soft / sdkjava / sdkjava.exe / SDKJava.cab / Samples / AFC / LoanCalc / Src / LCConsts.java < prev    next >
Encoding:
Java Source  |  1998-03-05  |  6.1 KB  |  207 lines

  1. //
  2. // (c) 1998 Microsoft Corporation.  All rights reserved.
  3. //
  4. public interface LCConsts
  5. {
  6.     public static final String IMG_NAMES[] = { 
  7.         "intro.gif",    "pvalue.gif",    "interest.gif",
  8.         "numper.gif",    "payment.gif",
  9.         "s_pvalue.gif",    "s_interest.gif",
  10.         "s_numper.gif",    "s_payment.gif"
  11.     };
  12.  
  13.     public static final int INTRO = 0;
  14.     public static final int PVALUE = 1;
  15.     public static final int INTEREST = 2;
  16.     public static final int NUMPERIODS = 3;
  17.     public static final int PAYMENT = 4;
  18.     public static final int S_PVALUE = 5;
  19.     public static final int S_INTEREST = 6;
  20.     public static final int S_NUMPERIODS = 7;
  21.     public static final int S_PAYMENT = 8;
  22.  
  23.     public static final int NUM_IMAGES = 9;
  24.  
  25.     public static final int IDX_IMG[] = { S_PVALUE, 
  26.                                           S_INTEREST,
  27.                                           S_NUMPERIODS,
  28.                                           S_NUMPERIODS,
  29.                                           S_PAYMENT };
  30.  
  31.     public static final String IDX_STR[] = {
  32.         "Loan Amount:",            "Interest Rate:",    "Length of Loan:", 
  33.         "Pmnt Frequency:",        "Payment Amount:" };
  34.  
  35.     public static final int IDX_PV = 0;
  36.     public static final int IDX_INT = 1;
  37.     public static final int IDX_LEN = 2;
  38.     public static final int IDX_FREQ = 3;
  39.     public static final int IDX_PMNT = 4;
  40.  
  41.     public static final int BL_NONE = 0;
  42.     public static final int BL_PV = 1;
  43.     public static final int BL_LEN = 2;
  44.     public static final int BL_PMNT = 3;
  45.  
  46.     public static final int INIT_PV = 10000;
  47.     public static final int INIT_RATE = 80;
  48.     public static final int INIT_LEN = 6;
  49.     public static final int INIT_FREQ = 0;
  50.  
  51.     public static final String INTRO_TXT = 
  52.         "Welcome to LoanCalc!\n\n    LoanCalc will calculate and display "+
  53.         "loan information given the loan parameters that you will enter. "+
  54.         "LoanCalc will calculate either your loan payment, the number "+
  55.         "of periods in your loan, or the amount of the loan. One of these "+
  56.         "three parameters must be left blank.";
  57.  
  58.     public static final String VALUE_TXT = 
  59.         "How much money are you borrowing?";
  60.     public static final int MAX_PV = 9999999;
  61.  
  62.     public static final String INTEREST_TXT = 
  63.         "At what interest rate (per annum)?";
  64.  
  65.     public static final int MIN_RATE = 24;
  66.  
  67.     public static final String PERIOD_TXT = 
  68.         "How much time do you want to take to pay off this loan?";
  69.     public static final String FREQ_TXT = "How often do you wish to make payments?";
  70.     public static final String FREQ_STR[] = {
  71.         "Monthly", "Every other month", "Every three months",
  72.         "Every four months", "Twice per year", "Yearly"
  73.     };
  74.     public static final int MAX_MONTHS = 35*12; // 35 years is maximum loan length
  75.     public static final int FREQ_FACTOR[] = { 12, 6, 4, 3, 2, 1 };
  76.     public static final int ID_MONTHS = 551;
  77.     public static final int ID_YEARS = 552;
  78.  
  79.     public static final String PMNT_TXT = "What size payment would you like to make?";
  80.  
  81.     public static final String FINAL_TXT = 
  82.         "All loan parameters have been entered.\n\n    LoanCalc will now calculate "+
  83.         "your payment schedule given the values that you have entered. "+
  84.         "If you would like to change any of the values press the 'Back' "+
  85.         "button, otherwise press the 'Finish' button to continue.\n\n"+
  86.         "    The calculation may take a few seconds.";
  87.  
  88.     public static final String LEN_CALC_PV =
  89.         "The loan amount has been left blank or set to zero.\n\n" +
  90.         "Either enter a value for the loan length, or press\n" +
  91.         "the 'Back' button twice and enter a value for the\n" +
  92.         "loan amount.";
  93.  
  94.     public static final String NUMPER_TOO_LARGE =
  95.         "Do you really think we will trust you with our\n" +
  96.         "money for that long?\n\n" +
  97.         "Please enter a smaller loan length. The duration\n" +
  98.         "of the loan must not exceed 35 years.\n";
  99.  
  100.     public static final String PMNT_CALC_PV =
  101.         "The loan amount has been left blank or set to zero.\n\n" +
  102.         "Either enter a value for the payment amount, or press\n" +
  103.         "the 'Back' button three times and enter a value for\n" +
  104.         "the loan amount.";
  105.  
  106.     public static final String PMNT_CALC_LEN =
  107.         "The length of the loan has been left blank or set to\n" +
  108.         "zero.\n\n" +
  109.         "Either enter a value for the payment amount, or press\n" +
  110.         "the 'Back' button and enter a value for the length of\n" +
  111.         "the loan.";
  112.  
  113.     public static final String PMNT_TOO_SMALL_INT =
  114.         "The payment you have entered is too small. You could\n" +
  115.         "not even pay the accrued interest with that payment.\n\n"+
  116.         "Either go to another bank, press the 'Back' button\n" +
  117.         "and change the other loan parameters, or enter a\n" +
  118.         "payment of at least ";
  119.  
  120.     public static final String PMNT_TOO_SMALL_LEN =
  121.         "The payment you have entered is too small. Do you want\n" +
  122.         "your grandchildren to be paying off this loan?\n\n" +
  123.         "Press the 'Back' button and change the other loan\n" +
  124.         "parameters, or enter a payment of at least ";
  125.  
  126.     public static final String PMNT_TOO_LARGE_PV =
  127.         "The payment you have entered would pay back a loan that\n" +
  128.         "far exceeds your financial means.\n\n" +
  129.         "Please enter a smaller payment or press the 'Back'\n" +
  130.         "button and change the other loan parameters.";
  131. }
  132.  
  133. class DNC
  134. {
  135.     private long i;
  136.  
  137.     public DNC(long j) { i = j; }
  138.  
  139.     public String toString()
  140.     {
  141.         String str;
  142.  
  143.         if ( i < 0 ) {
  144.             str = "-$";
  145.             i = -i;
  146.         }
  147.         else
  148.             str = "$";
  149.  
  150.         return str + DLRS.mkString(i/100) + "." + DLRS.mk2Digits(i % 100);
  151.     }
  152. }
  153.  
  154. class DLRS
  155. {
  156.     private long i;
  157.  
  158.     public DLRS(long j) { i = j; }
  159.  
  160.     public String toString() { return "$" + mkString(i); }
  161.  
  162.     public static String mkString(long i)
  163.     {
  164.         if ( i < 1000 )
  165.             return "" + i;
  166.         else
  167.             return mkString(i/1000) + "," + mk3Digits(i%1000);
  168.     }
  169.  
  170.     private static String mk3Digits(long i)
  171.     {
  172.         if ( i < 100 )
  173.             return "0" + mk2Digits(i);
  174.         else
  175.             return "" + i;
  176.     }
  177.  
  178.     public static String mk2Digits(long i)
  179.     {
  180.         if ( i < 10 )
  181.             return "0" + i;
  182.         else
  183.             return "" + i;
  184.     }
  185. }
  186.  
  187. class PRCNT
  188. {
  189.     private int i;
  190.  
  191.     public PRCNT(int j) { i = j; }
  192.  
  193.     public String toString()
  194.     {
  195.         String str = "" + i/8 + " ";
  196.         int j = i%8;
  197.         switch ( j ) {
  198.         case 0: return str + "%";
  199.         case 4: return str + "1/2 %";
  200.         case 1: case 3: case 5:    case 7: return str + j + "/8 %";
  201.         case 2:    case 6: return str + (j/2) + "/4 %";
  202.         }
  203.         // We will never get to here
  204.         return "";
  205.     }
  206. }
  207.