Junaid,
I think what you're looking for is the Period Class; located in the java.time package.
I won't bother delving into the logic behind your program. But what I gather is this:
You're trying to figure out how long it would take a person to become a millionaire based on working 40 hours a week, 5 days a week at a set wage. For example, $7.50 per hour. Now, keep in mind that work days differ; For example, a work week might be 40 hours per week in the US. But, 30 Hours a week in Europe. But
There are LOTS of variables to consider. But lets assume that it's a 40 hour week, 5 days a week @ 7.50 per hour.
You can figure that 7.50 * 40 is $300 per week.
300 per week * 4 (weeks per month) is 1200 per month. So if you take 1 million dollars and divide it by 1200 dollars per month that gives you 833.33 months.
833.33 months divide by 12 months per year is about 69.44 years. Lets just round down to 69 years.
Now using the
Period Class I mentioned above; you can obtain a period of 69 years like this.
Peroid p = Period.of(69,0,0);
Here's an example (lets say it took 69 years, 5 months and 3 days) to become a millionaire..
Period p = Period.of(69,5,3); //this is a period of 69 days, 5 months and 3 days.
Then you call methods on p like so:
p.getYears(); // returns 69;
p.getMonths(); // returns 5
p.getDays(); // returns 3
This entire reply is simply to direct you to the java.time package. Here's a link:
https://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html
There are MANY ways to approach this, But you're not providing enough details.
Hopefully this helps.