자바 saving account 를 공부하고있는데 class method 에서 막히네요

wndtjr2의 이미지

마지막에 total balance 와 total 입금, total 출금, total 이자 를 나타내야하는데 솔직히 class method 에 대해서 잘 이해를 못해서 뭐가몬지 모르겠습니다.
뭐가 문제고 class method 에대해서 예기좀 해주세요

import java.text.DecimalFormat;
 
import javax.swing.JOptionPane;
 
 
public class SavingAccount {
 
	public static void main(String[] args) {
 
		String intRate, stBalance, psMonth, input;
		double interRate, startBalance, depositIn, monthWith;
		int passMonth;
 
		DecimalFormat dollar = new DecimalFormat("##0.00");
 
		intRate = JOptionPane.showInputDialog("Enter the annual interest rate.");
		interRate = Double.parseDouble(intRate);
 
		stBalance = JOptionPane.showInputDialog("Enter the starting balance.");
		startBalance = Double.parseDouble(stBalance);
 
		SAccount sAccount = new SAccount(startBalance, interRate);
 
		psMonth = JOptionPane.showInputDialog("Enter the number of months that have passed since the account was established.");
		passMonth = Integer.parseInt(psMonth);
 
		for(int i = passMonth; i < 12; i++){
 
			input = JOptionPane.showInputDialog("Input the amount of money you want to deposit.");
			depositIn = Double.parseDouble(input);
			sAccount.setDeposit(depositIn);
 
			input = JOptionPane.showInputDialog("Input the amount of money you want to withdraw.");
			monthWith = Double.parseDouble(input);
			sAccount.setWithdrawal(monthWith);
			sAccount.setTotalInt(interRate);
		}JOptionPane.showMessageDialog(null, "total ending balance : " + dollar.format(sAccount.getBalance()) +
				"\ntotal amount of deposit : " + dollar.format(sAccount.getDeposit()) + 
				"\ntotal amount of withdral : " + dollar.format(sAccount.getwithdral()) +
				"\ntotal interest you earned : " + dollar.format(sAccount.getTotalInt()));
		System.exit(0);
	}
}

public class SAccount {
 
	private double interestRate, interest;
	private double balance;
	private double deposit;
	private double withdral;
 
 
	public SAccount(double bal,double intRate){
		balance = bal;
		interestRate = intRate;
	}
 
	public void setDeposit(double dposit){
		deposit += dposit;
	}
 
	public void setWithdrawal(double withd){
		withdral -= withd;
	}
 
	public void setIntRate(double rate){
		interestRate = rate;
	}
 
	public void setBalance(double bal){
		balance = bal;
		balance = deposit - withdral;	
		balance += balance;
	}
 
	public void setTotalInt(double intRate){
		interestRate = intRate; 
		interest = (interestRate / 12) * balance;
	}
 
	public double getDeposit(){
		return deposit;
	}
 
	public double getwithdral(){
		return withdral;
	}
 
	public double getBalance(){
		return balance;
	}
 
	public double getTotalInt(){
		return interest;
	}
}

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.