mport java.io.*;
import java.util.*;
public class Test1
{
/**
* @param args
*/
public static void main(String[] args)
{
// TODO 自動產生方法 Stub
Myprint1 myprint = new Myprint1();
myprint.mytest();
}
}
class Myprint
{
Myprint()
{
}
void mytest()
{
String inputs = "";
try
{
FileReader myinpufile = new FileReader("940305.SM");
BufferedReader isr = new BufferedReader(myinpufile);
//System.out.println(isr.readLine());
FileWriter myoutfile = new FileWriter("940305w.SM");
BufferedWriter isrw = new BufferedWriter(myoutfile);
int[][] a = new int[2][2];
int[][] b = new int[2][2];
int[][] c = new int[2][2];
for (int i = 1; i <= 1; i++)
{
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken = new StringTokenizer(inputs, ",");
a[0][0] = Integer.parseInt(mytoken.nextToken());
a[0][1] = Integer.parseInt(mytoken.nextToken());
//System.out.println(a[0][0]);
//System.out.println(a[0][1]);
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken2 = new StringTokenizer(inputs, ",");
a[1][0] = Integer.parseInt(mytoken2.nextToken());
a[1][1] = Integer.parseInt(mytoken2.nextToken());
//System.out.println(a[1][0]);
//System.out.println(a[1][1]);
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken3 = new StringTokenizer(inputs, ",");
b[0][0] = Integer.parseInt(mytoken3.nextToken());
b[0][1] = Integer.parseInt(mytoken3.nextToken());
//System.out.println(b[0][0]);
//System.out.println(b[0][1]);
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken4 = new StringTokenizer(inputs, ",");
b[1][0] = Integer.parseInt(mytoken4.nextToken());
b[1][1] = Integer.parseInt(mytoken4.nextToken());
//System.out.println(b[1][0]);
//System.out.println(b[1][1]);
c[0][0] = a[0][0] + b[0][0];
c[1][0] = a[1][0] + b[1][0];
c[0][1] = a[0][1] + b[0][1];
c[1][1] = a[1][1] + b[1][1];
System.out.println("\n[" + c[0][0] + " " + c[0][1] + "]");
System.out.println("\n[" + c[1][0] + " " + c[1][1] + "]");
isrw.write("\n[" + c[0][0] + " " + c[0][1] + "]");
isrw.write("\n[" + c[1][0] + " " + c[1][1] + "]");
}
isrw.flush();
myoutfile.close();
}
catch (Exception e)
{ }
System.out.println("Hello");
}
}
class Myprint1 extends Myprint
{
}
2010年6月11日 星期五
import java.io.*;
import java.util.*;
public class Test
{
/**
* @param args
*/
public static void main(String[] args)
{
// TODO 自動產生方法 Stub
Myprint1 myprint = new Myprint1();
mprint.mytest();
}
}
class Myprint
{
Myprint()
{
}
void mytest()
{
String inputs = "";
try
{
FileReader myinpufile = new FileReader("940305.SM");
BufferedReader isr = new BufferedReader(myinpufile);
//System.out.println(isr.readLine());
FileWriter myoutfile = new FileWriter("940305w.SM");
BufferedWriter isrw = new BufferedWriter(myoutfile);
int[][] a = new int[2][2];
int[][] b = new int[2][2];
int[][] c = new int[2][2];
for (int i = 1; i <= 1; i++)
{
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken = new StringTokenizer(inputs, ",");
a[0][0] = Integer.parseInt(mytoken.nextToken());
a[0][1] = Integer.parseInt(mytoken.nextToken());
//System.out.println(a[0][0]);
//System.out.println(a[0][1]);
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken2 = new StringTokenizer(inputs, ",");
a[1][0] = Integer.parseInt(mytoken2.nextToken());
a[1][1] = Integer.parseInt(mytoken2.nextToken());
//System.out.println(a[1][0]);
//System.out.println(a[1][1]);
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken3 = new StringTokenizer(inputs, ",");
b[0][0] = Integer.parseInt(mytoken3.nextToken());
b[0][1] = Integer.parseInt(mytoken3.nextToken());
//System.out.println(b[0][0]);
//System.out.println(b[0][1]);
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken4 = new StringTokenizer(inputs, ",");
b[1][0] = Integer.parseInt(mytoken4.nextToken());
b[1][1] = Integer.parseInt(mytoken4.nextToken());
//System.out.println(b[1][0]);
//System.out.println(b[1][1]);
c[0][0] = a[0][0] + b[0][0];
c[1][0] = a[1][0] + b[1][0];
c[0][1] = a[0][1] + b[0][1];
c[1][1] = a[1][1] + b[1][1];
System.out.println("\n[" + c[0][0] + " " + c[0][1] + "]");
System.out.println("\n[" + c[1][0] + " " + c[1][1] + "]");
isrw.write("\n[" + c[0][0] + " " + c[0][1] + "]");
isrw.write("\n[" + c[1][0] + " " + c[1][1] + "]");
}
isrw.flush();
myoutfile.close();
}
catch (Exception e)
{ }
System.out.println("Hello");
}
}
class Myprint1 extends Myprint
{
}
import java.util.*;
public class Test
{
/**
* @param args
*/
public static void main(String[] args)
{
// TODO 自動產生方法 Stub
Myprint1 myprint = new Myprint1();
mprint.mytest();
}
}
class Myprint
{
Myprint()
{
}
void mytest()
{
String inputs = "";
try
{
FileReader myinpufile = new FileReader("940305.SM");
BufferedReader isr = new BufferedReader(myinpufile);
//System.out.println(isr.readLine());
FileWriter myoutfile = new FileWriter("940305w.SM");
BufferedWriter isrw = new BufferedWriter(myoutfile);
int[][] a = new int[2][2];
int[][] b = new int[2][2];
int[][] c = new int[2][2];
for (int i = 1; i <= 1; i++)
{
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken = new StringTokenizer(inputs, ",");
a[0][0] = Integer.parseInt(mytoken.nextToken());
a[0][1] = Integer.parseInt(mytoken.nextToken());
//System.out.println(a[0][0]);
//System.out.println(a[0][1]);
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken2 = new StringTokenizer(inputs, ",");
a[1][0] = Integer.parseInt(mytoken2.nextToken());
a[1][1] = Integer.parseInt(mytoken2.nextToken());
//System.out.println(a[1][0]);
//System.out.println(a[1][1]);
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken3 = new StringTokenizer(inputs, ",");
b[0][0] = Integer.parseInt(mytoken3.nextToken());
b[0][1] = Integer.parseInt(mytoken3.nextToken());
//System.out.println(b[0][0]);
//System.out.println(b[0][1]);
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken4 = new StringTokenizer(inputs, ",");
b[1][0] = Integer.parseInt(mytoken4.nextToken());
b[1][1] = Integer.parseInt(mytoken4.nextToken());
//System.out.println(b[1][0]);
//System.out.println(b[1][1]);
c[0][0] = a[0][0] + b[0][0];
c[1][0] = a[1][0] + b[1][0];
c[0][1] = a[0][1] + b[0][1];
c[1][1] = a[1][1] + b[1][1];
System.out.println("\n[" + c[0][0] + " " + c[0][1] + "]");
System.out.println("\n[" + c[1][0] + " " + c[1][1] + "]");
isrw.write("\n[" + c[0][0] + " " + c[0][1] + "]");
isrw.write("\n[" + c[1][0] + " " + c[1][1] + "]");
}
isrw.flush();
myoutfile.close();
}
catch (Exception e)
{ }
System.out.println("Hello");
}
}
class Myprint1 extends Myprint
{
}
2010年6月10日 星期四
BMI值
import java.io.*;
import java.util.*;
import java.lang.Math;
public class Myjava0528 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO 自動產生方法 Stub
String inputs="";
double a,b,c,d,BMI;
try{
FileReader myinpufile=new FileReader("940304.SM");
BufferedReader isr=new BufferedReader(myinpufile);
//System.out.println(isr.readLine());
FileWriter myoutfile=new FileWriter("940304w.SM");
BufferedWriter isrw=new BufferedWriter(myoutfile);
for (int i=1;i<=3;i++)
{
inputs=isr.readLine();
isrw.write(inputs);
StringTokenizer mytoken=new StringTokenizer(inputs,",");
a = Double.parseDouble( mytoken.nextToken());
System.out.println(a);
b = Double.parseDouble( mytoken.nextToken());
System.out.println(b);
c = a / 100;
d= b / (c*c);
BMI=Math.round(d);
System.out.println(BMI);
if(BMI>=24)isrw.write("\n您的 BMI 指數是 "+BMI+",過重! ");
else if(BMI>=18.5)isrw.write("\n您的 BMI 指數是 "+BMI+",標準!");
else if(BMI<18.5)isrw.write("\n您的 BMI 指數是 "+BMI+",過輕!");
if(BMI>=24)System.out.printf("\n您的 BMI 指數是 "+BMI+",過重! ");
else if(BMI>=18.5)System.out.printf("\n您的 BMI 指數是 "+BMI+",標準!");
else if(BMI<18.5)System.out.printf("\n您的 BMI 指數是 "+BMI+",過輕!");
System.out.println("\n");
}
isrw.flush();
myoutfile.close(); }
catch(Exception e)
{ }
}
}
import java.util.*;
import java.lang.Math;
public class Myjava0528 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO 自動產生方法 Stub
String inputs="";
double a,b,c,d,BMI;
try{
FileReader myinpufile=new FileReader("940304.SM");
BufferedReader isr=new BufferedReader(myinpufile);
//System.out.println(isr.readLine());
FileWriter myoutfile=new FileWriter("940304w.SM");
BufferedWriter isrw=new BufferedWriter(myoutfile);
for (int i=1;i<=3;i++)
{
inputs=isr.readLine();
isrw.write(inputs);
StringTokenizer mytoken=new StringTokenizer(inputs,",");
a = Double.parseDouble( mytoken.nextToken());
System.out.println(a);
b = Double.parseDouble( mytoken.nextToken());
System.out.println(b);
c = a / 100;
d= b / (c*c);
BMI=Math.round(d);
System.out.println(BMI);
if(BMI>=24)isrw.write("\n您的 BMI 指數是 "+BMI+",過重! ");
else if(BMI>=18.5)isrw.write("\n您的 BMI 指數是 "+BMI+",標準!");
else if(BMI<18.5)isrw.write("\n您的 BMI 指數是 "+BMI+",過輕!");
if(BMI>=24)System.out.printf("\n您的 BMI 指數是 "+BMI+",過重! ");
else if(BMI>=18.5)System.out.printf("\n您的 BMI 指數是 "+BMI+",標準!");
else if(BMI<18.5)System.out.printf("\n您的 BMI 指數是 "+BMI+",過輕!");
System.out.println("\n");
}
isrw.flush();
myoutfile.close(); }
catch(Exception e)
{ }
}
}
迴文判斷
mport java.io.*;
import java.util.*;
public class Around0521 {
public static void main(String args[]) throws IOException{
FileReader inputjerry=new FileReader("940301.SM");
BufferedReader binputjerry=new BufferedReader(inputjerry);
// System.out.print("(迴文判斷)請輸入字母或數字:");
String s1=binputjerry.readLine();
String s2="";
for (int i=s1.length();i>0;i--){
char ch =s1.charAt(i-1);
s2=s2+ch;
}
if (s1.equals(s2)) System.out.println(s1+" is a palindrome"); //如果s1=s2
else System.out.println(s1+" is not a palindrome");
FileWriter outputjerry=new FileWriter("940301.T01");
BufferedWriter boutputjerry=new BufferedWriter(outputjerry);
if (s1.equals(s2)) boutputjerry.write(String.valueOf(s1+" is a palindrome"));
else boutputjerry.write(String.valueOf(s1+" is not a palindrome"));
boutputjerry.flush();
boutputjerry.close();
}
}
import java.util.*;
public class Around0521 {
public static void main(String args[]) throws IOException{
FileReader inputjerry=new FileReader("940301.SM");
BufferedReader binputjerry=new BufferedReader(inputjerry);
// System.out.print("(迴文判斷)請輸入字母或數字:");
String s1=binputjerry.readLine();
String s2="";
for (int i=s1.length();i>0;i--){
char ch =s1.charAt(i-1);
s2=s2+ch;
}
if (s1.equals(s2)) System.out.println(s1+" is a palindrome"); //如果s1=s2
else System.out.println(s1+" is not a palindrome");
FileWriter outputjerry=new FileWriter("940301.T01");
BufferedWriter boutputjerry=new BufferedWriter(outputjerry);
if (s1.equals(s2)) boutputjerry.write(String.valueOf(s1+" is a palindrome"));
else boutputjerry.write(String.valueOf(s1+" is not a palindrome"));
boutputjerry.flush();
boutputjerry.close();
}
}
長整數
mport java.io.*;
import java.util.*;
// inputtext.txt 檔案內容 COFFEE 50 4
// 從檔案讀入一列字串,讀入50 和 4 相乘再寫入另一檔案
class TestReadWrite0514
{
public static void main(String[] args)
{
String line,item,la,lb;
long num,price,total;
try
{
FileReader inputjerry=new FileReader("inputtext.txt");
BufferedReader binputjerry=new BufferedReader(inputjerry);
line=binputjerry.readLine();
StringTokenizer stline=new StringTokenizer(line, " ");
item=stline.nextToken();
System.out.println(item);
num=Long.parseLong(stline.nextToken()); //利用Long轉換String
System.out.println(num);
price=Long.parseLong(stline.nextToken());
System.out.println(price);
total=price+num;
System.out.println(total);
FileWriter outputjerry=new FileWriter("outputtext.txt");
BufferedWriter boutputjerry=new BufferedWriter(outputjerry);
boutputjerry.write(String.valueOf(total));
boutputjerry.flush();
boutputjerry.close();
}
catch(Exception e)
{
System.out.println("Exception");
}
}
}
import java.util.*;
// inputtext.txt 檔案內容 COFFEE 50 4
// 從檔案讀入一列字串,讀入50 和 4 相乘再寫入另一檔案
class TestReadWrite0514
{
public static void main(String[] args)
{
String line,item,la,lb;
long num,price,total;
try
{
FileReader inputjerry=new FileReader("inputtext.txt");
BufferedReader binputjerry=new BufferedReader(inputjerry);
line=binputjerry.readLine();
StringTokenizer stline=new StringTokenizer(line, " ");
item=stline.nextToken();
System.out.println(item);
num=Long.parseLong(stline.nextToken()); //利用Long轉換String
System.out.println(num);
price=Long.parseLong(stline.nextToken());
System.out.println(price);
total=price+num;
System.out.println(total);
FileWriter outputjerry=new FileWriter("outputtext.txt");
BufferedWriter boutputjerry=new BufferedWriter(outputjerry);
boutputjerry.write(String.valueOf(total));
boutputjerry.flush();
boutputjerry.close();
}
catch(Exception e)
{
System.out.println("Exception");
}
}
}
mport java.io.*;
import java.util.*;
// inputtext.txt 檔案內容 COFFEE 50 4
// 從檔案讀入一列字串,讀入50 和 4 相乘再寫入另一檔案
class TestReadWrite0514
{
public static void main(String[] args)
{
String line,item,la,lb;
long num,price,total;
try
{
FileReader inputjerry=new FileReader("inputtext.txt");
BufferedReader binputjerry=new BufferedReader(inputjerry);
line=binputjerry.readLine();
StringTokenizer stline=new StringTokenizer(line, " ");
item=stline.nextToken();
System.out.println(item);
num=Long.parseLong(stline.nextToken()); //利用Long轉換String
System.out.println(num);
price=Long.parseLong(stline.nextToken());
System.out.println(price);
total=price+num;
System.out.println(total);
FileWriter outputjerry=new FileWriter("outputtext.txt");
BufferedWriter boutputjerry=new BufferedWriter(outputjerry);
boutputjerry.write(String.valueOf(total));
boutputjerry.flush();
boutputjerry.close();
}
catch(Exception e)
{
System.out.println("Exception");
}
}
}
import java.util.*;
// inputtext.txt 檔案內容 COFFEE 50 4
// 從檔案讀入一列字串,讀入50 和 4 相乘再寫入另一檔案
class TestReadWrite0514
{
public static void main(String[] args)
{
String line,item,la,lb;
long num,price,total;
try
{
FileReader inputjerry=new FileReader("inputtext.txt");
BufferedReader binputjerry=new BufferedReader(inputjerry);
line=binputjerry.readLine();
StringTokenizer stline=new StringTokenizer(line, " ");
item=stline.nextToken();
System.out.println(item);
num=Long.parseLong(stline.nextToken()); //利用Long轉換String
System.out.println(num);
price=Long.parseLong(stline.nextToken());
System.out.println(price);
total=price+num;
System.out.println(total);
FileWriter outputjerry=new FileWriter("outputtext.txt");
BufferedWriter boutputjerry=new BufferedWriter(outputjerry);
boutputjerry.write(String.valueOf(total));
boutputjerry.flush();
boutputjerry.close();
}
catch(Exception e)
{
System.out.println("Exception");
}
}
}
訂閱:
文章 (Atom)