⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chapter4n1b.java

📁 JAVA源代码程序aashjkjhkjhkjhjkhkj
💻 JAVA
字号:
/* * program to demonstrate a more complicated "if" statement */import java.lancs.* ;public class Chapter4n1b    {    /*     * main     */    public static void main(String[] args) throws Exception	{	// read in values for the Person attributes	BasicIo.prompt("please type in the forename ") ;	String forename = BasicIo.readString() ;	BasicIo.prompt("please type in the surname ") ;	String surname = BasicIo.readString() ;	BasicIo.prompt("please type in the age ") ;        int age = BasicIo.readInteger() ;	BasicIo.prompt("please type in the gender ") ;        String response = BasicIo.readString() ;        int gender ;        if (response.equalsIgnoreCase("male"))            gender = Person.MALE ;        else if (response.equalsIgnoreCase("female"))            gender = Person.FEMALE ;        else            gender = Person.UNKNOWN ;        Person person1 = new Person(forename, surname, age, gender) ;        // output some information about the Person        System.out.print(person1.getForename() + ' ' + person1.getSurname()) ;        System.out.print(" is " ) ;        if (person1.getAge() < 13)            System.out.print("a child") ;        else if (person1.getAge() < 18)            System.out.print("a teenager") ;        else if (person1.getGender() == Person.FEMALE)            {            if (person1.getAge() < 60)                System.out.print("an adult") ;            else                System.out.print("a pensioner") ;            }        else            {            if (person1.getAge() < 65)                System.out.print("an adult") ;            else                System.out.print("a pensioner") ;            }        System.out.println() ;	} // end of method main    } // end of class Chapter4n1b

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -