새 파일에 읽기 파일을 인쇄 할 때 문제가 발생했습니다.파일을 읽지 만 새 파일로 보낼 때 제대로 인쇄되지 않습니까?
자본
2215.281234
위버, 애디슨 U.
902-6238 푸 루스 도로
관심
22343.623428
: 그래서 여기에 금융 파일에서 예를 들어 데이터의프로스트, 타나 Y.
P.O. 박스 902, 3494 Enim 도로
내가 그것을 실행하면, 내가 얻고 있었다 모든 것 :
이름 :
주소 :
등
그래서 "이름"후 또는 "주소"는 해당 이름을 표시하거나 해당 세금 코드를 추가하지 않습니다. 그러나 파일 쓰기를 읽습니다. 문제는 화면이나 파일에 이름과 주소를 인쇄하지 않는다는 것입니다. 누군가가 나를 도울 수 있다면 크게 감사하겠습니다. 인쇄는 제가 가지고있는 유일한 문제입니다. 미리 감사드립니다.
package fh;
import java.util.Scanner; import java.io.*;
public class fh { public static void main(String [] args) throws IOException
{
String taxcode ,name , address;
double tax = 0, income = 0;
String financeAdd = "C:\\Users\\name\\workspace\\finance.txt";
String correctRec = "C:\\Users\\name\\workspace\\taxrecords.txt";
String wrongRec = "C:\\Users\\name\\workspace\\recorderror.txt";
File file = new File(financeAdd);
Scanner s = new Scanner(file);
PrintWriter outfile = new PrintWriter(correctRec);
PrintWriter outfile2 = new PrintWriter(wrongRec);
while(s.hasNext())
{
taxcode = s.nextLine();
switch (taxcode)
{
case "Dividend":
income = Double.parseDouble(s.nextLine());
name = s.nextLine();
address = s.nextLine();
tax = (income * 1.25 - (income * 1.25 * 0.33)) * 0.22;
outfile.printf("%s%n%s%n","Name: ","Address: ", name, address);
System.out.printf("%s\n%s\n","Name: ","Address: ", name, address);
break;
case "Interest":
income = Double.parseDouble(s.nextLine());
name = s.nextLine();
address = s.nextLine();
tax = income * 0.22;
outfile.printf("%s%n%s%n","Name: ","Address: ", name, address);
System.out.printf("%s\n%s\n","Name: ","Address: ", name, address);
break;
case "Capital":
income = Double.parseDouble(s.nextLine());
name = s.nextLine();
address = s.nextLine();
tax = income * 0.50 * 0.22;
outfile.printf("%s%n%s%n","Name: ","Address: ", name, address);
System.out.printf("%s\n%s\n","Name: ","Address: ", name, address);
break;
default:
income = Double.parseDouble(s.nextLine());
name = s.nextLine();
address = s.nextLine();
outfile2.printf("%s%n%s%n","Name: ","Address: ", name, address);
System.out.printf("%s\n%s\n","Name: ","Address: ", name, address);
break;
}
}
System.out.println("Data Processed");
s.close();
outfile.flush();
outfile.close();
outfile2.flush();
outfile2.close();
}
}
정말 고마워요! 나는 약간만 조정해야하며 현재 작동 중입니다. 나는 이런 식으로 내 코드를 포맷하는 데 사용하고 이것은 처음으로 문제가 발생했습니다. –