We’re rewarding the question askers & reputations are being recalculated! Read more.
143
reputation
4

lukeb28

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);
    }
}
0
answers
1
question
~720
people reached
  • Member for 3 years, 11 months
  • 0 profile views
  • Last seen Jul 5 '16 at 17:55

Top tags (2)

Score 0
Posts 1
Score 0
Posts 1

Top posts (1) All Questions Answers | Votes Newest

Badges (4)

Gold

Silver

Bronze

4

Rarest