Challenge: if, else-if, else
Oppgave
Swipe to start coding
Write a program that reads an integer age from the user and prints the user's category based on the following rules:
- If the age is less than 18, print "child";
- If the age is 18 or older but less than 65, print "adult";
- If the age is 65 or older, print "senior".
Use if, else if, and else statements to implement this logic. Only print the category name ("child", "adult", or "senior").
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 3. Kapittel 14
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Fantastisk!
Completion rate forbedret til 1.25
Challenge: if, else-if, else
Sveip for å vise menyen
Oppgave
Swipe to start coding
Write a program that reads an integer age from the user and prints the user's category based on the following rules:
- If the age is less than 18, print "child";
- If the age is 18 or older but less than 65, print "adult";
- If the age is 65 or older, print "senior".
Use if, else if, and else statements to implement this logic. Only print the category name ("child", "adult", or "senior").
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 3. Kapittel 14
single