统计信息

  • 访问数:8782
  • 博客数:142
  • 建立时间:2008-01-05
  • 更新时间:2008-05-21
我叫王超然,是一名电脑爱好者,现在在新加坡留学上高一.我立志成为一名电脑人才,愿意在这里与大家一同分享我玩转电脑的心得.O-level华文考了A-One哈哈!

P5Q10

2008-04-09 08:40:39

天气: 晴朗 心情: 高兴

/*fileName:P5Q10.java
*Name:Wang Chaoran
* Description:
10 (Displaying characters)
Write a method that prints characters using the following header:
public static void printChars(char ch1, char ch2, int numberPerLine)
This method prints the characters between ch1 and ch2 with the specified
numbers per line. Write a test program that prints ten characters per line from '1' and 'Z.'
*/
public class P5Q10{
  public static void main(String[] args){
    printChars('1', 'Z', 10);
   
 
  }
  public static void printChars(char ch1, char ch2, int numberPerLine){
    for (int i=(int)(ch1);i<=(int)(ch2);i++){
       if(((i-(int)(ch1))%numberPerLine)==(numberPerLine-1))
      System.out.println((char)(i)+" ");
       else
         System.out.print((char)(i)+" ");
    }
  }
}
加入收藏 编辑 审核

TAG: computing

我来说两句

OPEN

Powered by X-Space 1.2 © 2001-2006 Comsenz Technology Ltd