Question
Write a program to input age of 5 players
ayers and count number of teenagers. (age 13 - 19)
Answers
Answered by
0
Answer:
Program:-
import java.util.*;
public class Players
{
public static void main(String args[ ])
{
Scanner in=new Scanner(System.in);
String name;
int age,tcount=0;
for(int a=1;a<=5;a++)
{
System.out.println("Enter the name of student");
name=in.nextLine();
System.out.println("Enter the age of student");
age=in.nextInt();
if(age>=13&&age<=19)
{
System.out.println("The boy is a teenager");
tcount++;
}
else
System.out.println("The boy is not a teenager");
}
System.out.println("Name="+name);
System.out.println("Age="+age);
System.out.println("Teenager count="+tcount);
}
}
Similar questions
English,
2 months ago
Physics,
2 months ago
History,
2 months ago
Computer Science,
4 months ago
Hindi,
10 months ago
History,
10 months ago
Psychology,
10 months ago