My program on compound interest gets compiled fine but it won't display anything .

Yesterday When I created a new class and tried to run a simple for loop , the same thing happened . But when I tried to run the same for loop in a previously made class , it ran just fine .

Source code :

class mangoes{
    public static void main(String[] args){

        double amount;
        double principal = 1000;
        double rate = .01;
        for(int day=1;day<=20;day++){
            amount=principal*Math.pow(1 + rate , day);

            System.out.println(day + "  "+ amount);
        }

    }

}

So is there some kind of problem with my eclipse ?

By using Eclipse you are adding layers of complexity to your task. I can't immediately see anything wrong with you code, so its probably something to do with your usage of Eclipse, eg the run configuration.
At your stage of learning you would be best advised to stick to a programmer's editor and the command line compiler. Eclipse is really a tool for expert users.

I ran that code here, runs just fine. it can be tons of reasons: maybe you didn't save the file, maybe you didn't re-compile, maybe you're running the wrong file, ..

I found the solution to this problem , it was my foolishness that caused it .

While creating the class I used to specify a different name and then while coding I used to write a different name for the class :P.
So this caused the problem .

Anyways thanks for all the help .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.