Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

 WAP to calculate age where the son is 20 years younger than the father and 18 years younger than the mother what will be the age of the son, father, and mother, calculation start year will be entered by the user?



year=2002


son age  18

father age 38

mother age 36


Program Answer:-


import java.util.Scanner;

class CalculateAge

{


   public static void main(String args[])

   {

        int year,fage,mage,sage;

        

        Scanner sc = new Scanner(System.in);

        System.out.println("Enter year");

        year = sc.nextInt();

        sage = 2020-year;

        fage = sage + 20;

        mage = sage + 18;

        System.out.println("Son Age is "+sage);

        System.out.println("Father Age is "+fage);

        System.out.println("Mother Age is "+mage);

         

         

 

   }




}




Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post