package data;
public class Bank {
private String accountNumber;
private String accountHolder;
private String phone;
private String email ;
private double balance = 50000;
public Bank(String accountNumber, String accountHolder, String phone, String email, double balance) {
this.accountNumber = accountNumber;
this.accountHolder = accountHolder;
this.phone = phone;
this.email = email;
this.balance += balance;
}
public void manageBankAccount() {
System.out.println("Here is your account profile");
System.out.printf("|Account Number: %-17s|Account Holder: %-18s|Phone: %-10s|Email: %-26s|Balance: %10.2fVNĐ|\n", accountNumber, accountHolder, phone, email, balance);
}
}
package btvn;
import data.Bank;
import java.util.Scanner;
public class BTVN {
public static void main(String[] args) {
Scanner keyBoard = new Scanner(System.in);
for (int i = 1; i < 4; i++) {
String accountNumber = keyBoard.nextLine(), accountHolder = keyBoard.nextLine(), phone = keyBoard.nextLine(), email = keyBoard.next();
double balance = keyBoard.nextDouble();
switch (i) {
case 1:
Bank bankAccount1 = new Bank(accountNumber, accountHolder, phone, email, balance);
System.out.println("Account Bank 1");
bankAccount1.manageBankAccount();
break;
case 2:
Bank bankAccount2 = new Bank(accountNumber, accountHolder, phone, email, balance);
System.out.println("Account Bank 2");
bankAccount2.manageBankAccount();
break;
case 3:
Bank bankAccount3 = new Bank(accountNumber, accountHolder, phone, email, balance);
System.out.println("Account Bank 3");
bankAccount3.manageBankAccount();
break;
}
}
}
}
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:864)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextDouble(Scanner.java:2413)
at btvn.BTVN.main(BTVN.java:14)
C:\Users\Admin\AppData\Local\NetBeans\Cache\12.3\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\Admin\AppData\Local\NetBeans\Cache\12.3\executor-snippets\run.xml:94: Java returned: 1