I have to create a program to calculate the number of years it will take to become a millionaire if i invest a certain amount and receive interest on it. I need a little help on how to start it, the only thing i have so far is we have to invest yearly
invest
interest = invest * the rate (int. rate)
invest = invest + the interest

then we have to display a comment about the amount of money we are investing like, if is say 200 the print statement would say something like You would be waiting a decade to become a millionaire with that investment, try increasing it. and so on.
Is there anyone that would be willing to help with is program?

Only if you start with an effort to outline your thoughts on how to implement the program or some code that you have written to start with.

Write it in pseudocode if you don't understand how to do it in Java and ask specific questions about the portions that you are unsure of.

thats the pseudocode i have so far im so lost thats why im requesting help

import java.util.Scanner;
import java.text.DecimalFormat;

public class Millionaire
{

public static void main(String args[ ])
{

double = invest;
double = interest;

Scanner scan = new Scanner(System.in);

interest = invest * the rate (int. rate)
invest = invest + the interest

double millionaire = invest + interest

//Rounds the answer to 2 decimal places
DecimalFormat fmt = new DecimalFormat("0.##");
System.out.println("Number of years it will take you to become a millionaire: " + fmt.format(millionaire));
}

}

Perhaps you need to look up pseudocode then, because you have nothing like it.

You need to outline the steps in a logical format that describes the process the program needs to complete.

well thats how i always wrote my pseudocode, i also posted the java code i have so far

i had a very bad java teacher in the past and thats why im retaking it now and thats why i dont understand the most simpliest stuff

well thats how i always wrote my pseudocode, i also posted the java code i have so far

i had a very bad java teacher in the past and thats why im retaking it now and thats why i dont understand the most simpliest stuff

Before you think about Java, you have to think about the math and how interest is calculated and how loans are calculated. Think about how you would calculate this if you didn't have a computer, write it out on paper. So if you don't know how to calculate loans, that's something you need to know before starting to code.

heres an update on what my code looks like, does anyone have any import of possible fixes?

import java.util.Scanner;
import java.text.DecimalFormat;

public class Millionaire
{

public static void main(String args[ ])
{

double = invest;
final double = rate;

Scanner scan = new Scanner(System.in);

System.out.println ("Please enter an amount you would like to invest: " );
invest =  scan.nextDouble();

System.out.println ("At what interest rate: " );
invest =  scan.nextDouble();


interest = invest * rate
invest = invest + rate 


//Rounds the answer to 2 decimal places
DecimalFormat fmt = new DecimalFormat("0.##");

System.out.println("Number of years it will take you to become a millionaire: " + fmt.format(invest));
}

heres an update on what my code looks like, does anyone have any import of possible fixes?

import java.util.Scanner;
import java.text.DecimalFormat;

public class Millionaire
{

public static void main(String args[ ])
{

double = invest;
final double = rate;

Scanner scan = new Scanner(System.in);

System.out.println ("Please enter an amount you would like to invest: " );
invest =  scan.nextDouble();

System.out.println ("At what interest rate: " );
invest =  scan.nextDouble();


interest = invest * rate
invest = invest + rate 


//Rounds the answer to 2 decimal places
DecimalFormat fmt = new DecimalFormat("0.##");

System.out.println("Number of years it will take you to become a millionaire: " + fmt.format(invest));
}

I assume this is supposed to be rate, not invest on one of the lines. You have this line twice.

invest =  scan.nextDouble();
System.out.println("Number of years it will take you to become a millionaire: " + fmt.format(invest));

invest is in dollars and cents. It's not a measure of time. You never calculate how long it'll take in years and you don't have a variable to represent time. You need to either find or derive some math formulas to compute the time from one million, the amount invested, and the interest rate.

The second formula is way off:

interest = invest * rate
invest = invest + rate

You can't add a rate to money. I assume it's supposed to be this:

interest = invest * rate
invest = invest + interest

but it's still not going to get you the length of time and it's not legal Java code (no semicolons). Did you try compiling this?

no its not complied yet my complier isnt working
so im kinda relying on my code working until i can bring it to class and run it.

import java.util.Scanner;
import java.text.DecimalFormat;

public class Millionaire
{

public static void main(String args[ ])
{

double = invest, years;
final double = rate;

Scanner scan = new Scanner(System.in);

System.out.println ("Please enter an amount you would like to invest: " );
double invest =  scan.nextDouble();

System.out.println ("At what interest rate: " );
double rate =  scan.nextDouble();


rate = (invest * rate * years) / 100;
invest = invest + interest; 
years = invest*Math.pow(rate, y);

//Rounds the answer to 2 decimal places
DecimalFormat fmt = new DecimalFormat("0.##");

System.out.println("Number of years it will take you to become a millionaire: " + (invest));

}

}

thanks for taking the time to help me

no its not complied yet my complier isnt working
so im kinda relying on my code working until i can bring it to class and run it.

that's one lazy-ass compiler you've got there.
propably means you haven't installed one yet.

and what you said in your earlier posts, that you had "a bad teacher, and thus had to retake the course"

...

life is not like the Karate Kid movies... a failing student mostly has himself to blame. (been lazy for a few years too, but never went so far as to blame my teachers for that)

you do not know pseudocode, otherwise you would have realised that your first post was not pseudocode, just the assignment your teacher gave you (and no, they usually don't give assignments in pseudocode or nasi-schneidermann diagrams)

if you really don't want to flunk out again: install a compiler, test your code and see if it's working before you go and ask people about the problems that might be in it.
compilation errors give you a pretty good idea about where to look for the problem (if there is any) and if it's an exception thrown at runtime, check your error messages. you can learn much more of them than to ask others to review your code without thinking about it yourself

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.