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.

+5
Answers (1)
  1. 15 June, 13:07
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers