Ad Code

✨🎆 Diwali Dhamaka Offer! 🎆✨

Get 20% OFF on All Courses at Shiva Concept Solution click

WAP to calculate age where the son is 20 years younger than ...?

 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);

         

         

 

   }




}




إرسال تعليق

0 تعليقات