Java 第五週
上課錄影
http://www.powercam.cc/slide/1133
//-----------------------------------------------------------------------------
import java.io.*;
import java.util.*;
//import java.io.PrintStream;
//import java.io.BufferedOutputStream;
//import java.io.FileOutputStream;
class Myfifthjava{
static String output = "";
public static void main(String args[]){
String InFileName,OutFileName;
try{
InFileName=args[0];//在執行時需要給檔名,例如 java Myfifthjava test.txt
System.out.print("Input File Name:" + InFileName + "\n" );
StringTokenizer tokens = new StringTokenizer( InFileName, ".t");;// 必須有".t"引數
File position = new File(InFileName);
OutFileName = tokens.nextToken() + ".w" + tokens.nextToken();
BufferedReader input = new BufferedReader(new FileReader( position ) );
int num = Integer.parseInt(input.readLine());
System.out.println(num);
File text = new File(OutFileName);
BufferedWriter output1 = new BufferedWriter(new FileWriter( text) );
output1.write(""+num);
output1.flush();
}catch(Exception e)
{
System.err.println(e);
}
}
}
class Addop
{
double x;
double y ;
public double z;
Addop()
{
x=1;
y=2;
z=x/y;
System.out.println("z="+z);
}
}
許老師結合數學與電腦程式的教學網 課程包含 程式設計 數值分析 -------------------------------------- Prof. Hsu teaches computer programming and numerical analysis to help those who wants to be a computer programming master and focus on controlling computers to benefit people more than only on making money.
關於我自己
- 許志宇(Chih-Yu Hsu)
- Welcome to discuss about : Chinese Traditional Medicine and Acupuncture Please send me the email: tccnchsu@gmail.com Chih-Yu Hsu
12 則留言:
/*D9539108 陸靖文*/
import java.util.StringTokenizer;
import java.io.*;
class FB {
public static void main (String[] args) {
String InputFile, OutputFile;
int num=0,multi=1;
InputFile=args[0];
System.out.println("輸入名稱:"+InputFile);
StringTokenizer st=new StringTokenizer(InputFile,".");
OutputFile=st.nextToken()+".w"+st.nextToken();
System.out.println("輸出名稱:"+OutputFile);
try{
BufferedReader input = new BufferedReader(new FileReader(InputFile ) );
num = Integer.parseInt(input.readLine());
System.out.println(num);
}
catch(Exception e){
System.out.println("錯誤訊息:"+e);
}
for(int j=1; j<=num ; j++){
multi*=j;
System.out.println("做第幾次:"+j);
System.out.println(j+"階乘="+multi);
}
}
}
D9377831 劉羽程
---------------------------------
import java.io.*;
import java.util.*;
import java.util.StringTokenizer;
class myfifthjava
{
public static void main(String[] args)
{
int num=0,sumall=1;
String InputFile,OutputFile;
InputFile=args[0];
System.out.println("InputFilename:"+InputFile);
StringTokenizer st = new StringTokenizer(InputFile,".");
OutputFile=st.nextToken()+".w"+st.nextToken();
System.out.println("OutputFilename:"+OutputFile);
File position = new File(InputFile);
try
{
BufferedReader input = new BufferedReader(new FileReader( position ) );
num = Integer.parseInt(input.readLine());
System.out.println(num);
}
catch(Exception e)
{
System.out.println("Error:"+e);
}
for(int j=1; j<=num; j++)
{
sumall= sumall*j ;
System.out.println(sumall);
}
}
}
/*D9476668 陳秋宇*/
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.File;
class Myfirstjava
{
public static void main(String[] args)
{
String InputFile,OutFile;
int num=0,sumall=1;
InputFile=args[0];
System.out.println("InputFilename"+InputFile);
StringTokenizer st = new StringTokenizer(InputFile,".");
OutFile=st .nextToken()+".w"+st .nextToken();
System.out.println("OutputFilename"+OutFile);
File position = new File(InputFile);
try{
BufferedReader input = new BufferedReader(new FileReader( position ) );
num = Integer.parseInt(input.readLine());
System.out.println(num);
}
catch(Exception e){
System.out.println("錯誤:"+e);
}
for(int j=1; j<=num ; j++)
{
sumall=sumall*j;
System.out.println(sumall);
}
}
}
/*d9582608*/
/*廖仁龍*/
import java.util.StringTokenizer;
import java.io.*;
class dark5
{
public static void main(String [] args)
{
int num = 0,sumall=1;
try
{
String InputFile,OutputFile;
InputFile = args[0];
System.out.println("InputFile="+InputFile);
StringTokenizer st = new StringTokenizer(InputFile,".");
OutputFile =st.nextToken()+".w"+st.nextToken();
System.out.println("OutputFile="+OutputFile);
File position = new File (InputFile);
BufferedReader input = new BufferedReader(new FileReader( position ) );
num = Integer.parseInt(input.readLine());
System.out.println(num);
}
catch(Exception e)
{
System.out.println("你錯啦笨蛋="+e);
}
for(int j=1; j<=num ; j++)
{
sumall=sumall*j;
System.out.println(sumall);
}
}
}
//第五週作業 D9539125 黃培熏
import java.io.*;
import java.util.StringTokenizer;
class HPS_005
{
public static void main(String[] args)
{
int num=1,sum=1;
String InputFileName=args[0], OutputFileName="";
File position = new File(InputFileName);
System.out.println(InputFileName);
StringTokenizer st = new StringTokenizer( InputFileName, ".");
OutputFileName+=st.nextToken()+".txt";
System.out.println(OutputFileName);
try
{
BufferedReader input = new BufferedReader(new FileReader( position ) );
num = Integer.parseInt(input.readLine());
System.out.println(num);
for (int i=num;i>=1;i--)
{
if (i==0)
sum*=1;
else
sum*=i;
System.out.println(sum);
}
System.out.println("sum="+sum);
}
catch(Exception e)
{
System.out.println("Error:"+e);
}
}
}
D9476995 應數四乙 辛為儒
import java.util.StringTokenizer;
import java.io.*;
class java5
{
public static void main(String[] args)
{
int num = 0,sumall=1;
String InputFile,OutputFile;
InputFile = args[0];
System.out.println("InputFileName is "+InputFile);
StringTokenizer st = new StringTokenizer(InputFile,".");
OutputFile = st.nextToken() + ".w" + st.nextToken();
System.out.println("OutputFileName is " + OutputFile);
File position = new File(InputFile);
try{
BufferedReader input = new BufferedReader(new FileReader(position));
num = Integer.parseInt(input.readLine());
System.out.println(num);
}
catch(Exception e)
{
System.out.println("Error"+e);
}
for (int j=1; j <= num; j++)
{
sumall = sumall * j;
System.out.println(sumall);
}
}
}
*D9788173 王則元*/
import java.util.StringTokenizer;
import java.io.File;
import java.io.BufferedReader;
import java.io.FileReader;
class Myfifthjava
{
public static void main(String [] args)
{
int num=0,summation=1;
String InputFile,OutputFile;
InputFile=args[0];
System.out.println("InputFileName:"+InputFile);
StringTokenizer st = new StringTokenizer(InputFile, ".");
OutputFile=st.nextToken()+".w"+st.nextToken();
System.out.println("OutputFileName:"+OutputFile);
File position = new File(InputFile);
try
{
BufferedReader input = new BufferedReader(new FileReader( position ) );
num = Integer.parseInt(input.readLine());
System.out.println(num);
}
catch(Exception e)
{
System.out.println("Error:"+e);
}
for(int j=1; j<=num ; j++)
summation=summation*j;
{
System.out.println(summation);
}
}
}
/*D9582256 高岱群 */
import java.util.StringTokenizer;
import java.io.File;
import java.io.BufferedReader;
import java.io.FileReader;
class ra1
{
public static void main(String[] args)
{
int num=0,sumall=1;
String Inportfile,Outfile;
Inportfile=args[0];
StringTokenizer st = new StringTokenizer(Inportfile,".");
Outfile=st.nextToken()+".w"+st.nextToken();
System.out.println("Inportfile:"+Inportfile);
System.out.println("Outfile:"+Outfile);
File position=new File(Inportfile);
try
{
BufferedReader input = new BufferedReader(new FileReader( position ) );
num = Integer.parseInt(input.readLine());
System.out.println(num);
}
catch(Exception e)
{
System.out.println("ERRER:"+e);
}
for (int i=1; i<=num; i++)
{
sumall=sumall*i;
System.out.println(sumall);
}
}
}
import java.util.StringTokenizer;
import java.io.*;
class Myfifthjava
{
public static void main(String[] args)
{
String InputFile,OutFile;
int num=0;
int sumall=1;
InputFile=args[0];
System.out.println("InputFileName"+InputFile);
StringTokenizer st = new StringTokenizer(InputFile,".");
OutFile=st.nextToken()+".w"+st.nextToken();
System.out.println("OutputFileName:"+OutFile);
File position= new File(InputFile);
try{
BufferedReader input = new BufferedReader(new FileReader( position ) );
num = Integer.parseInt(input.readLine());
System.out.println(num);
}
catch(Exception e)
{
System.out.println("Error:"+e);
}
for(int j=1; j<=num ; j++)
{
sumall=sumall*j;
System.out.println(sumall);
}
}
}
//D9582506 黃鉦權
import java.util.StringTokenizer;
import java.io.*;
class Myfirstjava
{
public static void main(String[] args)
{
String Inputfile,OutFile;
int num=0,sumall=1;
Inputfile=args[0];
File position=new File(Inputfile);
System.out.println("InputFileName"+Inputfile);
StringTokenizer st = new StringTokenizer(Inputfile,".");
//System.out.println(st.nextToken());
OutFile=st.nextToken( )+".w"+st.nextToken();
System.out.println("OutputFileName"+OutFile);
try{
BufferedReader input = new BufferedReader(new FileReader( position ) );
num = Integer.parseInt(input.readLine());
System.out.println(num);
}
catch(Exception e)
{
System.err.println(e);
}
for(int j=1;j<=num;j++)
{
sumall=sumall*j;
System.out.println(sumall);
}
}
}
//應數三甲 D9538864 徐晟哲
import java.io.*;
import java.util.StringTokenizer;
class Myfourjava
{
public static void main(String[] args)
{
String InputFile,OutFile;
int num=0,sumall=1;
InputFile=args[0];
System.out.println("InputFileName"+InputFile);
StringTokenizer st = new StringTokenizer(InputFile ,"." );
OutFile=st.nextToken()+".w"+st.nextToken();
System.out.println("OutputFilename"+OutFile);
File position=new File(InputFile);
try{
BufferedReader input=new BufferedReader(new FileReader(position));
num =Integer.parseInt(input.readLine());
System.out.println(num);
}
catch(Exception e){
System.out.println("Error"+e);
}
for(int j=1;j<=num;j++)
{
sumall=sumall*j;
System.out.println(sumall);
}
}
}
//光電四D9427925施宇鴻
import java.util.StringTokenizer;
import java.io.*;
class Myfifthjava
{
public static void main(String[] args)
{
int num;
num=1;
String InputFile,OutFile;
InputFile=args[0];
System.out.println("InputFileName"+InputFile);
StringTokenizer st = new StringTokenizer(InputFile,".");
//while (st.hasMoreTokens()) {
//System.out.println(st.nextToken());
OutFile=st.nextToken()+".w"+st.nextToken();
System.out.println("OutFileName"+OutFile);
// }
File position=new File(InputFile);
try{
BufferedReader input = new BufferedReader(new FileReader( position ) );
num = Integer.parseInt(input.readLine());
System.out.println(num);
}
catch(Exception e)
{
System.out.println("Error:"+e);
}
int allsum;
allsum=1;
for(int j=1; j<=num ; j++)
{
allsum = allsum*j;
System.out.println(allsum);
}
}
}
張貼留言