+ 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!!
28 ответов
+ 16
age = int(input())
if age <= 11:
print("Child")
elif( age >= 12 and age <= 18 ):
print("Teen")
else:
print("Adult")
+ 3
age = int(input())
if age >= 0 and age < 12:
print("Child")
elif age >= 12 and age <= 18:
print("Teen")
else:
print("Adult")
+ 3
I've tried like every code I can think of nothing works
+ 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 .
+ 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
+ 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");
}
}
}
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')
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")
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")
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")
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")
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")
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")
0
age=int(input())
if age<11:
print("Child")
if(age >=12 and age<=18):
print("Teen")
else :
print("Adult")
0
Here are the age groups you need to handle:
Child: 0 to 11 Teen: 12 to 17
Adult: 18 to 64
0
age = int(input())
if age <= 11:
print("Child")
elif( age >= 12 and age <= 18 ):
print("Teen")
else:
print("Adult")
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.
0
try this one
it's worked...
age = int(input())
if age <= 11:
print('Child')
elif age <= 18:
print('Teen')
else:
print('Adult')
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")
}
}
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