Ive는 input = nextLine()을 시도하고 String 데이터에 입력을 추가했지만 여전히 null을 반환합니다. 여기서 가능한 문제가 될 수 있습니까?파일에 기록 된 출력이 왜 0입니까? 내 코드의 문제점은 무엇입니까?
[철회 방법]
public void Withdraw(){
System.out.print("Enter withdrawal amount:");
double withdraw = input.nextDouble();
System.out.println("Your withdrawal amount: " + withdraw);
if(this.balance - withdraw < 100){
System.out.println("The maintaining balance should not be less than 100. ");
}else
this.balance -= withdraw;
System.out.println("Your new balance is:" + this.balance);
}
[파일에 추가 여기서
public void withdrawWriter(){
try{
String data = "Your withdrawal amount: " + withdraw;
File file = new File(this.name + ".txt");
//if file doesnt exists, then create it
if(!file.exists()){
file.createNewFile();
}
//true = append file
FileWriter fileWritter = new FileWriter(file.getName(),true);
BufferedWriter bufferWritter = new BufferedWriter(fileWritter);
bufferWritter.write("\r\n");
bufferWritter.write(data);
bufferWritter.close();
System.out.println("Done");
}catch(IOException e){
e.printStackTrace();
}
}
는 스크린 샷입니다 :