JAvaメソッドによる銀行預金操作の実現

1642 ワード

public class YinHang {
	//         ,      。
	static double sum=1000;
	static java.util.Scanner sc=new java.util.Scanner(System.in);
	public static void main(String[] args) {				
		while(true){
		System.out.println("       ");
		int  i=sc.nextInt();
		if (i==10){
			//  1 2 3           
			System.out.println("    ,       "+sum+"
1 2 0 "); int k=sc.nextInt(); if(k==1){ Deposit(); } if(k==2){ WithDraw(); } }else{ System.out.println(" , "); continue; } } } public static void Deposit(){ System.out.println(" , "); while(true){ // System.out.println(" :"); double money=sc.nextInt(); // sum=sum+money; System.out.println(" "+money+" "+" "+sum); System.out.println(" 1, 0"); // 1 0 int jx=sc.nextInt(); if(jx==0){ break; }else{ continue; } } } public static void WithDraw(){ System.out.println(" , "); while(true){ // System.out.println(" :"); double money2=sc.nextInt(); // if(money2>sum){ System.out.println(" , "); break; } sum=sum-money2; System.out.println(" "+money2+" "+" "+sum); System.out.println(" 1, 0"); // 1 0 int jx=sc.nextInt(); if(jx==0){ break; }else{ continue; } } } }