chapter5n4.java

来自「JAVA源代码程序aashjkjhkjhkjhjkhkj」· Java 代码 · 共 52 行

JAVA
52
字号
/** * * demonstration of the "while" statement * * Written by: Roger Garside * * First Written: 12/June/96 * Last Rewritten: 2/Oct/96 * */import java.lancs.* ;public class Chapter5n4    {    /**     *     * main     *     */    public static void main(String[] args) throws Exception        {        GroupOfPeople computing = new GroupOfPeople() ;        String s ;        System.out.println("Type a surname followed by 'return'") ;        System.out.println("(type 'return' when there are no more surnames)") ;        s = BasicIo.readString() ;        while (s.length() != 0)	    {	    computing.addSurname(s) ;	    System.out.println("inserted surname " + s) ;	    System.out.println("Type a surname followed by 'return'") ;         System.out.println("(type 'return' when there are no more surnames)") ;            s = BasicIo.readString() ;	    }        System.out.print("There are " + computing.getCount()) ;        System.out.println(" people in the group") ;        for (int i = 0 ; i < computing.getCount() ; i++)            {            System.out.print("The " + (i + 1) + "th surname is ") ;            System.out.println(computing.getSurname(i)) ;            }        } // end of method main    } // end of class Chapter5n4

⌨️ 快捷键说明

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