Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Exercise_3;
- import java.util.Scanner;
- public class Task_3_4 {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int a;
- int balance = 0, q = 1, w = 0;
- String name = "";
- System.out.printf("- - - - Welcome to Bank of Hkr - - - - %n1) New account %n2) View account %n3) Deposit %n4) Withdraw %n5) Exit %n- - - - - - - - - - - - - - - - - - - -%n");
- while (q == 1) {
- if (w > 0) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- System.out.printf("- - - - - - - - - - - - - - - - - - - -%n1) New account %n2) View account %n3) Deposit %n4) Withdraw %n5) Exit%n- - - - - - - - - - - - - - - - - - - -%n");
- }
- w++;
- System.out.println("Please input your choice ");
- a = input.nextInt();
- input.nextLine();
- switch (a) {
- case 1:
- System.out.println("Please enter your name for your new account");
- name = input.nextLine();
- System.out.println("You account's name is: " + name);
- break;
- case 2:
- if (name.equals("")) {
- System.out.println("There are no registered accounts.");
- }
- else {
- System.out.println("Here's the information of your account\nName:");
- System.out.println(name);
- System.out.println("Your balance is = " + balance + " SEK");
- }
- break;
- case 3:
- if (name.equals("")) {
- System.out.println("There are no registered accounts.");
- }
- else {
- System.out.println("How much money would you like to deposit?");
- balance += input.nextInt();
- System.out.println("Your new balance is = " + balance + " SEK");
- }
- break;
- case 4:
- if (name.equals("")) {
- System.out.println("There are no registered accounts.");
- }
- else {
- System.out.println("How much money would you like to withdraw?");
- balance -= input.nextInt();
- System.out.println("Your new balance is = " + balance + " SEK");
- }
- break;
- case 5:
- System.out.println("Thank you for visiting our bank");
- q = 0;
- break;
- default:
- System.out.println("Error: Wrong number");
- break;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment