0

I was doing compound interest program with switch case where one case was display term deposit while the other one was recurring deposit.

I almost finished the program and I had no errors, but when I executed my own program, after i pressed an option, my source code box opened up and said "empty string at sun.misc.floatingdecimal".

I don't know what that means, and I need help!

This was my code:

import java.io.*;

class Bank {
    public static void main (String args[]) throws IOException {
        InputStreamReader read = new InputStreamReader(System.in);
        BufferedReader in = new BufferedReader(read);
        System.out.println("For Term Deposit press T. for Recurring Deposit, press R.");
        char a;
        a = (char) in.read();
        double output;
        switch (a) {
            case 'T':
                System.out.println("Enter the pricipal, Rate,and time period in years.");
                double P, r, A; 
                int n;
                P = Double.parseDouble(in.readLine());
                r = Double.parseDouble(in.readLine());
                n = Integer.parseInt(in.readLine());
                A = P * Math.pow(1+r / 100, n);
                System.out.println("The Maturity amount is + " + A);
                break;
            case 'R':
                System.out.println("Enter your monthly deposit, rate of interest and time period in months.");
                double deposit, rate, MV; 
                int months;
                deposit = Double.parseDouble(in.readLine());
                rate = Double.parseDouble(in.readLine());
                months = Integer.parseInt(in.readLine());
                MV = deposit*months+deposit*months*(months+1)/2*rate/100*1/12;
                System.out.println("Maturity Value = " + MV);
                break;
            default:
                System.out.println("Wrong choice!");
        }
    }
}
Seth
  • 1,490
  • 1
  • 14
  • 28
Adithi
  • 1
  • A couple of notes that might help. Please indent the code so it is easier to read. That probably would help the reader sift through the code to figure out what's happening. Also what other efforts have you taken to debug the problem? Did you put in logging or some System.out.println() statements to figure out what's going on? One final note is that you might want to proofread your questioon. The postings up here are often used later by other users and if they find similar problems, it helps if the question is clear. – Dale Oct 07 '16 at 14:09
  • You're doing `a = (char) in.read();` and not consuming the new line, before reading from your Scanner again. Refer to the linked question. – Tunaki Oct 07 '16 at 14:31

0 Answers0