Hello, This is my first time posting and I'd like to thank you guys in advance and I'm glad I have a resource to help me when I'm completely over my head. I just began a java course and I had to write a program that would display the population each year for five years. I used a linear population increase. But I cannot get the answers to format in an easily recognizable number. I know I could use the int variable, but I'm supposed to be as accurate and it displays as 3.14812582703967E8. Please help and thank you.
public class Population { public static void main(String[] args) { // TODO Auto-generated method stub double births = 60 / 7.0; double birthsPerHour = births * 60; double birthsPerDay = birthsPerHour * 24; double birthsPerYear = birthsPerDay * 365; //births over a year double deaths = 60 / 13.0; double deathsPerHour = deaths * 60; double deathsPerDay = deathsPerHour * 24; double deathsPerYear = deathsPerDay * 365;//deaths over a year double immigrants = 60 / 45.0; double immigrantsPerHour = immigrants * 60; double immigrantsPerDay = immigrantsPerHour * 24; double immigrantsPerYear = immigrantsPerDay * 365;//immigrants over a year int population = 312032486; double population1 = (population + birthsPerYear + immigrantsPerYear) - deathsPerYear; System.out.println("The population for year 1 is " + population1); //print population year 1 double population2 = (population1 + immigrantsPerYear + birthsPerYear) - deathsPerYear; System.out.println("The population for year 2 is " + population2); //print population year 2 double population3 = (population2 + immigrantsPerYear + birthsPerYear) - deathsPerYear; System.out.println("The population for year 3 is " + population3);//print population year 3 double population4 = (population3 + immigrantsPerYear + birthsPerYear) - deathsPerYear; System.out.println("The population for year 4 is " + population4); //print population year 4 double population5 = population4 + immigrantsPerYear + birthsPerYear - deathsPerYear; System.out.println("The population for year 5 is " + population5); //print population year 5 } }