我叫王超然,是一名电脑爱好者,现在在新加坡留学上高一.我立志成为一名电脑人才,愿意在这里与大家一同分享我玩转电脑的心得.O-level华文考了A-One哈哈!
天气: 晴朗
心情: 高兴
/*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)+" ");
}
}
}
导入论坛查看(61)回复(0)引用(0)好评(0) 差评(0)
加入收藏
编辑
审核
TAG:
computing