+ 3

Boolean Logic: Output their age group

Boolean Logic Given the age of a person as input, you need to output their age group. Here are the age groups you need to handle: Child: 0 to 11 Teen: 12 to 17 Adult: 18 to 64 Senior: 65+ Sample Input 42 Sample Output Adult My code: age = int(input()) # your code goes here if age >= 0 and < 12: print("Child") elif age > 11 and < 18: print:("Teen") elif age > 17 and <65: print("Adult") elif age > 64: print("Senior") else: print("Invalid age") I keep getting Syntax error in the first line. Any advice would be appreciated!!

8th Aug 2021, 3:25 AM
Riley
28 ответов
+ 16
age = int(input()) if age <= 11: print("Child") elif( age >= 12 and age <= 18 ): print("Teen") else: print("Adult")
19th Dec 2021, 4:46 PM
‎باسط احمد‎
+ 3
age = int(input()) if age >= 0 and age < 12: print("Child") elif age >= 12 and age <= 18: print("Teen") else: print("Adult")
20th Dec 2021, 8:46 AM
Lema Kefyalew
Lema Kefyalew - avatar
+ 3
I've tried like every code I can think of nothing works
4th Aug 2022, 2:07 AM
Godwin Coughan
Godwin Coughan - avatar
+ 2
// // import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int age = sc.nextInt(); if (age >= 0 && age <= 11) { System.out.println("Child"); } else if (age >= 12 && age <= 17) { System.out.println("Teen"); } else if (age >= 18 && age <= 64) { System.out.println( "Adult"); } else if (age > 64) { System.out.println( "Senior"); } } } //this is the correct java code for this problem .
10th Aug 2023, 6:16 AM
alekhya madabattula
alekhya madabattula - avatar
+ 1
age=int(input()) if age>0 and age<=11: print( "Child") elif age>=12 and age<=17 : print ( "Teen") elif age>=18 and age<=64: print( "Adult") use it 100% work and all check point
30th Oct 2022, 8:05 AM
Abhishek Maheshwari
Abhishek Maheshwari - avatar
+ 1
// Working code import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int age = sc.nextInt(); if (age >= 0 && age <= 11) { System.out.println("Child"); } else if (age >= 12 && age <= 17) { System.out.println("Teen"); } else if (age >= 18 && age <= 64) { System.out.println( "Adult"); } else if (age > 64) { System.out.println( "Senior"); } } }
21st Feb 2024, 6:17 AM
Irfan Alam
Irfan Alam - avatar
0
age=int(input('Enter the age: ')) if(age>=0 and age<=11): print('child') elif(age>=12 and age<=17): print('teen') elif(age>=18 and age<=64): print('adult') else: print('senior')
21st Dec 2021, 4:55 PM
SANVIKA
0
age = int(input()) if age >= 0 and age <=11: print("Child") elif age >= 12 and age <=17: print("Teen") elif age >= 18 and age <= 64: print("Adult") else: print("Senior")
8th Jan 2022, 1:49 PM
Ihor Princ
Ihor Princ - avatar
0
age=int(input()) # codes are here if age>=0 and age<=11 : print("Child") elif age>=12 and age<=17: print("Teen") elif age>=18 and age<=64: print("Adult") else: print("Invalid input")
29th Jan 2022, 2:27 PM
Souvik Pal
0
Try This! It works age = int(input()) # your code goes here if age>= 0 and age<=11: print("Child") elif age>=12 and age<=17: print("Teen") elif age >=18 and age<=64: print("Adult") elif age > 64: print("Senior")
31st Jan 2022, 11:18 AM
JAMESHA IBRAHIM K
JAMESHA IBRAHIM K - avatar
0
age = int(input()) if age > 0 and age < 12: print('Child') elif age > 11 and age < 18: print('Teen') elif(age>17 and age < 65): print('Adult') else: print("Senior")
15th Feb 2022, 2:33 PM
Alcino Castelo
0
/*Here it is your answer*/ age = int(input()) if (age >= 0 and age <= 11): print("Child") elif (age >=12 and age <= 17): print("Teen") elif (age >= 18 and age <= 64): print("Adult")
20th May 2022, 9:01 PM
Hamza Limam Eibba
Hamza Limam Eibba - avatar
0
age = int(input()) if age <= 11: print("Child") elif (age >=12 and age <= 17): print("Teen") elif (age >=18 and age <= 64): print("Adult") else: print("Invalid input")
31st Aug 2022, 9:28 PM
Nidae El mouhib
Nidae El mouhib - avatar
0
age=int(input()) if age<11: print("Child") if(age >=12 and age<=18): print("Teen") else : print("Adult")
29th Sep 2022, 12:02 PM
Nagasiva Vakadani
Nagasiva Vakadani - avatar
0
Here are the age groups you need to handle: Child: 0 to 11 Teen: 12 to 17 Adult: 18 to 64
6th Dec 2022, 12:34 AM
LK videos
LK videos - avatar
0
age = int(input()) if age <= 11: print("Child") elif( age >= 12 and age <= 18 ): print("Teen") else: print("Adult")
18th Mar 2023, 8:31 PM
المهندس أحمد
المهندس أحمد - avatar
0
Draw a flowchart to accept a user's age and determine and print whether the user is a child (under 18), à youth (18 or older but under 40), or a senior (40 or older) then calculate & print his age after 10 years.
18th Apr 2023, 8:53 AM
0
try this one it's worked... age = int(input()) if age <= 11: print('Child') elif age <= 18: print('Teen') else: print('Adult')
2nd Jun 2023, 6:25 AM
Mehedi Hasan
Mehedi Hasan - avatar
0
fun main(args: Array<String>) { var age = readLine()!!.toInt() if(age<0) print("Invalid age") else {if (age>0 && age<=11) print( "Child") else if (age>=12 && age<=17 ) print ( "Teen") else if (age>=18 && age<=64) print( "Adult") else print( "Senior") } }
2nd Jul 2023, 8:35 AM
Ghada Bejaoui
Ghada Bejaoui - avatar
0
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int age = sc.nextInt(); String ageGroup; // Use if-else statements to determine the age group based on the age if (age >= 0 && age <= 11) { ageGroup = "Child"; } else if (age >= 12 && age <= 17) { ageGroup = "Teen"; } else if (age >= 18 && age <= 64) { ageGroup = "Adult"; } else { ageGroup = "Senior"; // Assuming age 65 and above are considered seniors } // Output the age group System.out.println(ageGroup); } } In this program, we use Scanner to read the user's input for the age of the person. We then use if-else statements to determine the age group based on the input age. If the age falls within a certain range, the corresponding age group is assigned to the variable ageGroup. If the age doesn't match any of the specified ranges (e.g., if it's greater than 64), the program considers the person as a "Senior." The program will output the determined age group based on the input age. Sample Input: 42 Sample Output:Adult This output indicates that the age group for an age of 42 falls within the "Adult" category, as expected. The program will categorize ages into the correct groups as per the given conditions. credit : www.lawtantra.org
2nd Aug 2023, 8:41 AM
Novi
Novi - avatar