Ask Question
17 March, 19:39

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.

+1
Answers (1)
  1. 17 March, 22:43
    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?
Not Sure About the Answer?
Get an answer to your 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 ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers