package ch07; import java.util.Scanner; /** * Created by liwenj on 2017/7/19. */ public class newCom { String name; int age; public void mes(){ if (age<5||age>=80){ System.out.println(name+"的年龄是:"+age+"岁,免费进入游览"); }else{ System.out.println(name+"的年龄是:"+age+"岁,欢迎光临"); } } } class Person{ public static void main(String[] args) { newCom person=new newCom(); Scanner input=new Scanner(System.in); System.out.print("请输入游客姓名:"); person.name=input.next(); System.out.print("请输入游客年龄:"); person.age=input.nextInt(); person.mes(); } }