import java.util.Scanner;
public class ContaCorrente { public static void main(String[] args) { String name = "Marcelo Aires das Neves"; String numberType = "Current"; double balance = 1599.99; int options = 0; double newValue; double amountTransfer = 0;
System.out.println("***************************");
System.out.println("Client data: \n");
System.out.println("Name: " + name);
System.out.println("Account Type: " + numberType);
System.out.println("Initial Balance: " + balance);
System.out.println("***************************\n");
String menu = """
\nMenu Options
1- Check the Balance
2- Transfer Amount
3- Enter the Amount
4- Exit
\nChoose the options:""";
Scanner reading = new Scanner(System.in);
while (options != 4) {
System.out.print(menu);
options = reading.nextInt();
//4- Exit
if (options == 4) {
System.out.println("Exit the transactions Account.");
}
else if (options >= 5) {
System.out.println("Selection the number options Menu between (1, 2, 3 and 4)");
}
//1- Check the Balance
else if (options == 1) {
balance = balance;
System.out.println("The balance is " + balance);
}
//2- Transfer Amount
else if (options == 2) {
System.out.print("Insert the value to transfer: ");
amountTransfer = reading.nextDouble();
if (amountTransfer <= 0){
System.out.println("You need to insert the value more than Zero.");
balance += amountTransfer;
}
if (amountTransfer > balance){
System.out.println("Isn't possible to transfer, You haven't money.");
System.out.printf("Your balance is $%.2f. Insert the limite value or less.", balance);
System.out.print("\nInsert the transfer value to transfer: ");
amountTransfer = reading.nextDouble();
balance -= amountTransfer;
System.out.println("The balance is " + balance);
}else if(amountTransfer <= balance) {
balance -= amountTransfer;
System.out.println("The balance is " + balance);
}
}
//3- Enter the Amount
else if (options == 3) {
System.out.print("Insert the value to account: ");
newValue = reading.nextDouble();
if (newValue <= 0){
System.out.println("You need to insert the value more than Zero.");
newValue = 0;
}else {
//System.out.println("You need to insert the value more than Zero.");
balance += newValue;
System.out.println("The balance is " + balance);
}
}
}
}
}