Ask Question
22 July, 10:42

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.

+5
Answers (1)
  1. 22 July, 11:46
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers