Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Java to achieve the effect of outputting age groups according to age values

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report