153,093 views
42 votes
42 votes
Write a multi-way if 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

User Joel Larson
by
2.9k points

1 Answer

16 votes
16 votes

Note, this is psudocode, because i dont know what language you are coding in.

define a variable: minors

define a variable: adults

define a variable: seniors

define a variable: age

if age <18{

add one to minors

}

else if 18<age<64{

add one to adults

}

else if age >= 65{

add one to seniors

}

User Max Strini
by
2.8k points