How to use Java to achieve the effect of outputting age groups according to age values
This article mainly explains "how to use Java to achieve the effect of outputting age groups according to age values." Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "how to use Java to output age group effect according to age value"!
Title:
According to age, print out the current age of the person is juvenile (under 18), youth (19-28), middle age (29-55), old age (56 +)
Java code implementation
import java.util.Scanner;
public static void main0(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Please enter the age of this person: ");
int age = scan.nextInt();
if(age>=0 && age=19 && age=29 && age=56){
System.out.println("old");
}
}
We enter a numerical value, and the program prints out the age range.
Second, print 1-100 prime numbers
Title:
Prints prime numbers between 1 and 100
Java code implementation
public static void main(String[] args) {
int i=1;
int j=2;
int count=0;
for(i=1;i