lukeb28
  • Member for 5 years, 11 months
  • Last seen more than 5 years ago
About

Total Coding Newbie that's going to be asking a ton of dumb questions :)

Here's my latest project!

package money;
import java.awt.Component;
import javax.swing.JOptionPane;
public class Money
{
    private static Component frame;
    public static void main(String[] args)
    {
        int d = 0;
        boolean fin = true;
        Double[] z = new Double[3];
        do
        {
            String x = JOptionPane.showInputDialog("Please enter the initial value, followed by the annual \nincrease as a percentage per year, then the term in years\nseparated with a ',' and without spaces. (eg. 1,2,3)");
            x += ",";
            int a = 0, y = -1;
            for(int i = 0; i < x.length(); i++)
            {
                if(x.charAt(i) == ',')
                {
                    z[a] = Double.parseDouble(x.substring((y + 1), i));
                    y = i;
                    a++;
                }
            }
            while(z[2] > d && z[2] <= 15)
            {
                d++;
                z[0] *= (1 + z[1]/100);
            }
            if(z[2] > 15)
            {
                JOptionPane.showMessageDialog(frame, "The length of time of the investment is too long! \nPlease enter a length of less than 15 years.");
            }
            else
            {
                JOptionPane.showMessageDialog(frame, "The final amount will be $" + (Math.floor(z[0] * 100) / 100.0));
                fin = false;
            }
        }while(z[2] >= 15 && fin);
    }
}
Badges
This user doesn’t have any gold badges yet.
This user doesn’t have any silver badges yet.
4
bronze badges
Top tags
0
Score
1
Posts
100
Posts %
0
Score
1
Posts
100
Posts %