fork download
  1. /*
  2.  * Copyright (c) 2013 AWOLart.com
  3.  */
  4.  
  5. package com.awolart.fin.cu.ps2;
  6.  
  7. import java.text.NumberFormat;
  8.  
  9. /**
  10.  * Suppose the current term structure of interest rates, assuming
  11.  * annual compounding, is as follows:
  12.  * s1 s2 s3 s4 s5 s6
  13.  * 7.0% 7.3% 7.7% 8.1% 8.4% 8.8%
  14.  *
  15.  * What is the discount rate d(0,4)?
  16.  *
  17.  * (Recall that interest rates are always quoted on an annual basis
  18.  * unless stated otherwise.)
  19.  *
  20.  * Please submit your answer rounded to three decimal places;
  21.  * i.e., if your answer is 0.4567 then you should submit 0.457.
  22.  */
  23. public class TermStructureForwardRate {
  24.  
  25.  
  26.  
  27.  
  28. }
  29.  
  30.  
  31.  
  32.  
  33. /**
  34.   * Convenience main method to facilitate command line/ide testing.
  35.   *
  36.   * @param args
  37.   */
  38. public static void main(String[] args) {
  39.  
  40. NumberFormat formatter = NumberFormat.getNumberInstance();
  41. formatter.setMaximumFractionDigits(2);
  42. formatter.setMinimumFractionDigits(4);
  43.  
  44. /* PS1/Q3 */
  45. double t = 2.0;
  46. double s1 = 0.063;
  47. double s2 = 0.069;
  48. double d_0_2 = TermStructureForwardRate.discountRate(s2, t);
  49. System.out.println("d(0,2) = " + formatter.format(d_0_2));
  50.  
  51.  
  52. /* PS2/Q1 */
  53. double[] s = { 0.070, 0.073, 0.077, 0.081, 0.084, 0.088 };
  54. t = 4;
  55. double d_0_4 = TermStructureForwardRate.discountRate(s[3], t);
  56. System.out.println("d(0,4) = " + formatter.format(d_0_4));
  57.  
  58. }
  59.  
  60. }
  61.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:38: error: class, interface, or enum expected
    public static void main(String[] args) {
                  ^
Main.java:41: error: class, interface, or enum expected
        formatter.setMaximumFractionDigits(2);
        ^
Main.java:42: error: class, interface, or enum expected
        formatter.setMinimumFractionDigits(4);
        ^
Main.java:45: error: class, interface, or enum expected
        double t = 2.0;
        ^
Main.java:46: error: class, interface, or enum expected
        double s1 = 0.063;
        ^
Main.java:47: error: class, interface, or enum expected
        double s2 = 0.069;
        ^
Main.java:48: error: class, interface, or enum expected
        double d_0_2 = TermStructureForwardRate.discountRate(s2, t);
        ^
Main.java:49: error: class, interface, or enum expected
        System.out.println("d(0,2) = " + formatter.format(d_0_2));
        ^
Main.java:53: error: class, interface, or enum expected
        double[] s = { 0.070, 0.073, 0.077, 0.081, 0.084, 0.088 };
        ^
Main.java:54: error: class, interface, or enum expected
        t = 4;
        ^
Main.java:55: error: class, interface, or enum expected
        double d_0_4 = TermStructureForwardRate.discountRate(s[3], t);
        ^
Main.java:56: error: class, interface, or enum expected
        System.out.println("d(0,4) = " + formatter.format(d_0_4));
        ^
Main.java:58: error: class, interface, or enum expected
    }
    ^
13 errors
stdout
Standard output is empty