请完成下列Java程序:实现打印出自己的源文件的功能。
注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。
import java.io.*;
import java.util.StringTokenizer;
public class ex27_2{
public static void main(String args[])throws IOException{
FileInputStream fis=new FileInputStream("ex27_2.java");
DataInputStream dis=new DataInputStream(fis);
String str=null;
while(true){
__________________;
if(str==null){
__________________;
}
StringTokenizer st=new StringTokenizer(str);
while(st.hasMoreTokens()){
System.out.print(st.nextToken()+ " " );
}
System.out.println();
}
}
}
第1题:
下面的程序是用do-while语句计算10的阶乘。请在程序的每条横线处填写1个语句,使程序的功能完整。
注意:请勿改动main()主方法和其他已有的语句内容;仅在横线处填入适当的语句。
源程序文件代码清单如下:
public class DoWhileLoop
{
public static void main(______)
{
int n=10;
long result=1;
do
{
_____;
}
_____;
System.out.println("10的阶乘为:"+result);
}
}
第2题:
下面的程序是用do_while语句计算10的阶乘。请在程序的每条横线处填写一个语句,使程序的功能完整。
注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。
源程序文件代码清单如下:
public class DoWhileLoop
{
public static void main(________)
{
int n=10;
long result=1;
do
{
_______________
}
______________
System.out.println("10的阶乘为: "+result);
}
}
第3题:
请完成下列Java程序。程序的输出结果:a=6,b=5。
注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。
程序运行结果如下:
public class ex38_2{
public static void main(String args[])
{
int a=5,b=6;
a=_________;
b=a-b;
a=_________;
System.out.println("a="+a+"\tb="+b);
}
}
第4题:
下面的程序的功能是简单的进行键盘输入测试,请在程序的每条横线处填写一个语句,使程序的功能完整。
注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。
____________________
public class TestKeyBoardInPut
{public static void main(String[] args)
{String yourname=JOptionPane. ____________________ ("What is your name?");
System.out.println("Hello"+yourname);
____________________.exit(0);
}
}
第5题:
下面的程序是打印输出100~300之间的不能被3整除的数。请在每条横线处填写一条语句,使程序的功能完整。
注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填人适当的语句。
public class printNo3and5{
void print()
{
int n ;
for(n=100 ;n<=300 ;n++){
if(n%3==0)
__________
System.out.println(n);
}
}
public static__________main(String args[])
{
printNo3and5 bj=new printN03and5();
__________
}
}