代码如下:
//progame:Print a tringle of stars
import java.io.*;
public class TringleOfstars
{
static BufferedReader keyboard=
new BufferedReader(new InputStreamReader(System.in)); public static void main(String[]args)throws IOException
{
int numberoflines;
int counter;
int numberofblanks; System.out.print("Enter the number of star lines (1 to 20)"
+"to be pront-->");
System.out.flush();
numberoflines=Integer.parseInt(keyboard.readline());
while(numberoflines <0||numberoflines>20);
{
System.out.print("number of star lines should be"
+"between 1 and 20");
System.out.print("Enter the number of star lines(1 to 20)to be printed-->");
System.out.flush();
numberoflines=Integer.parseInt(keyboard.readLine());
}
numberofblanks=30;
for(counter=1;counter <=numberoflines;counter++)
{
printstars(numberofblanks,counter);
numberofblanks--;
}
} public static void printstars(int blanks,int starsinline)
{
int count;
for(count=1;count <=blanks;count++)
System.out.print("");
for(count=1;count <=starsinline;count++)
System.out.print("*");
}
}
调试结果:
D:\mj>javac TringleOfstars.java
TringleOfstars.java:17: 找不到符号
符号: 方法 readline()
位置: 类 java.io.BufferedReader
numberoflines=Integer.parseInt(keyboard.readline());
^
1 错误 我是新手,请指点下啊
//progame:Print a tringle of stars
import java.io.*;
public class TringleOfstars
{
static BufferedReader keyboard=
new BufferedReader(new InputStreamReader(System.in)); public static void main(String[]args)throws IOException
{
int numberoflines;
int counter;
int numberofblanks; System.out.print("Enter the number of star lines (1 to 20)"
+"to be pront-->");
System.out.flush();
numberoflines=Integer.parseInt(keyboard.readline());
while(numberoflines <0||numberoflines>20);
{
System.out.print("number of star lines should be"
+"between 1 and 20");
System.out.print("Enter the number of star lines(1 to 20)to be printed-->");
System.out.flush();
numberoflines=Integer.parseInt(keyboard.readLine());
}
numberofblanks=30;
for(counter=1;counter <=numberoflines;counter++)
{
printstars(numberofblanks,counter);
numberofblanks--;
}
} public static void printstars(int blanks,int starsinline)
{
int count;
for(count=1;count <=blanks;count++)
System.out.print("");
for(count=1;count <=starsinline;count++)
System.out.print("*");
}
}
调试结果:
D:\mj>javac TringleOfstars.java
TringleOfstars.java:17: 找不到符号
符号: 方法 readline()
位置: 类 java.io.BufferedReader
numberoflines=Integer.parseInt(keyboard.readline());
^
1 错误 我是新手,请指点下啊
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货