Ask Question

Write an if/else statement that compares the variable age with 65, adds 1 to the variable seniorCitizens if age is greater than or equal to 65, and adds 1 to the variable nonSeniors otherwise. Assume all variables have been declared.

+3
Answers (1)
  1. 11 October, 16:00
    0
    if (age>=65)

    {

    seniorCitizens=seniorCitizens+1;

    System. out. println ("seniorCitizens counting is="+seniorCitizens);

    }

    else

    {

    nonSeniors=nonSeniors+1;

    System. out. println ("nonSeniors counting is="+nonSeniors);

    }

    Explanation:

    In the above java program, if age will be more than or equal to 65 so seniorCitizens counting will be increased by 1 and if it will be less than 65 so 1 will be increased in nonSeniors.
Know the Answer?
New Questions in Computers & Technology