Population Program in Java


In a town, the percentage of men is 52. The percentage of total literacy is 48. If total percentage of literate men is 35 of the total population, write a program to find the total number of illiterate men and women if the population of the town is 80,000.


This Java program computes various statistics related to a population of 80,000 individuals. The program calculates the following values:

  • popmen: the total number of men in the population, assuming that they represent 52% of the total population.
  • popwomen: the total number of women in the population, assuming that they represent the remaining 48% of the population.
  • poplit: the total number of literate individuals in the population, assuming that they represent 48% of the total population.
  • litmen: the number of literate men in the population, assuming that 35% of the men are literate.
  • litwomen: the number of literate women in the population, computed as the difference between the total number of literate individuals and the number of literate men.
  • unlitmen: the number of men who are not literate, computed as the difference between the total number of men and the number of literate men.
  • unlitwomen: the number of women who are not literate, computed as the difference between the total number of women and the number of literate women.
  • Finally, the program prints out all of these values using the System.out.println statement.

Source Code

class Populationa
{
	public static void main(String args[])
	{
		int pop=80000;
		int popmen=(52*pop)/100;
		int popwomen=pop-popmen;
		int poplit=(48*pop)/100;
		int litmen=(35*popmen)/100;
		int litwomen= poplit-litmen;
		int unlitmen=popmen-litmen;
		int unlitwomen=popwomen-litwomen;
		System.out.println("Total Population          : "+pop);
		System.out.println("Total Mens                : "+popmen);
		System.out.println("Total Womens              : "+popwomen);
		System.out.println("Total Literacy            : "+poplit);
		System.out.println("Total Literacy Mens       : "+litmen);
		System.out.println("Total Literacy Womens     : "+litwomen);
		System.out.println("Total Not Literacy Mens   : "+unlitmen);
		System.out.println("Total Not Literacy Womens : "+unlitwomen);
	}
}

Output

Total Population          : 80000
Total Mens                : 41600
Total Womens              : 38400
Total Literacy            : 38400
Total Literacy Mens       : 14560
Total Literacy Womens     : 23840
Total Not Literacy Mens   : 27040
Total Not Literacy Womens : 14560