145k views
0 votes
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.

if (age < 18) Then
minors += 1
ElseIf (age < 65) Then
adults += 1
Else
seniors += 1
End If

User Mike Chiu
by
6.1k points

1 Answer

5 votes

Answer:

if (age < 18) // check condition of variable age is less than 18

minors=minors+`1;

else if (age >=18 && age <=64) //check condition of variable age between 18 to 64

adults=adults+1;

else // check condition of variable age more than 65

seniors=seniors+1;

Step-by-step explanation:

Here we checks the condition if the variable age is less than 18 then it increment the value of variable 'minors' by 1 i.e, minors=minors+`1; .

if variable age is 18 through 64 then it increment the value of variable adults by 1 i.e,'adults'=adults+1; otherwise increment the value of variable 'seniors ' by 1 i.e seniors=seniors+1;

User Reenie
by
5.6k points