Ask Question
3 May, 22:01

Write an if/else statement that adds 1 to the variable minors if the variable age is less than 18, adds 1 to the variable adults if age is 18 through 64 and adds 1 to the variable seniors if age is 65 or older.

+3
Answers (1)
  1. 3 May, 22:23
    0
    if (age<18) {

    minors+=1;

    }

    else if (age>18 && age<65) {

    adults+=1;

    }

    else{

    seniors+=1;

    }

    Explanation:

    A java program with the variables created and initialized is given below:

    import java. util. Scanner;

    public class num3 {

    public static void main (String[] args) {

    Scanner in = new Scanner (System. in);

    System. out. println ("Enter Age: ");

    int age = in. nextInt ();

    int minors = 16;

    int adults = 20;

    int seniors = 70;

    if (age<18) {

    minors+=1;

    }

    else if (age>18 && age<65) {

    adults+=1;

    }

    else{

    seniors+=1;

    }

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write an if/else statement that adds 1 to the variable minors if the variable age is less than 18, adds 1 to the variable adults if age is ...” 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