QUESTION IMAGE
Question
2 essay 10 points write a program that prints \adult\ if age is greater than 18, otherwise prints \child\.
Step1: Define age variable
We can take age as an input or assign a value. Let's assume we take input. In Python, we can do age = int(input("Enter age: ")) to get the age as an integer.
Step2: Use conditional statement
Use an if-else statement to check the condition. If age > 18, print "Adult", else print "Child". The code would be:
age = int(input("Enter age: "))
if age > 18:
print("Adult")
else:
print("Child")Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
The Python program to solve this is as follows:
age = int(input("Enter age: "))
if age > 18:
print("Adult")
else:
print("Child")
(If using other programming languages like Java, the code would be:
import java.util.Scanner;
public class AgeCheck {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int age = sc.nextInt();
if (age > 18) {
System.out.println("Adult");
} else {
System.out.println("Child");
}
sc.close();
}
}
But the Python version is more concise for a basic example.)