The suspected violation of this floor has been folded by the system   Hide this building view this building

public class Account { // Initial deposit

float count = 0f;// Current account balance

int money1;// Number of deposits , int money2;// Withdrawal amount /*

* deposit

*/

public float saveMoney() {

count += money1;

return count;

} /*

* withdraw money

*/

public float getMoney() {

if (count == 0) {

System.out.println(" Your balance is insufficient "); } else {

count -= money2;

System.out.println(" Your balance is insufficient "); }

return count;

}

}

/*

* Simulate bank deposit and withdrawal business

*/

import java.util.Scanner; public class TestBan {

public static void main(String[] args) {

boolean isOk = false;

Account st = new Account();

Scanner sc = new Scanner(System.in); do {

System.out.println("1. deposit 2. withdraw money 0 sign out ");

System.out.print(" Please select the business you need to handle :");

int num = sc.nextInt();

switch (num) {

case 1:

System.out.print(" Please enter the deposit amount :");

st.money1 = sc.nextInt();

float a = st.saveMoney();

System.out.println(" Deposit successful ");

System.out.println("\n*** Current balance is " + a + " element ***\n");

isOk = true;

break;

case 2:

System.out.print(" Please enter the withdrawal amount :");

st.money2 = sc.nextInt();

if (st.count == 0||st.count

System.out.println(" Your balance is insufficient \n");

} else {

float b = st.getMoney();

System.out.println(" Withdrawal succeeded ");

System.out.println("\n*** Current balance is " + b + " element ***\n");

}

isOk = true;

break;

case 0:

System.out.println(" Thank you for using !");

isOk = false;

break;

default:

break;

}

} while (isOk);

}

}

Technology