Im trying to keep the FinalBal updated within the while loop but it doesn't. I think I need to add code to keep the FinalBal updated. I'm just praticing for a test. My class in college is basic java. Here is my code:
import java.util.Scanner;
public class TestPraticeBank {
public static void main(String[] args) {
int balance = 100;
int TotalBal;
int CurBal;
int amount;
Scanner keyboard = new Scanner(System.in);
System.out.print("1. Deposit\n" +
"2. Withdrawal\n" +
"3. View\n" +
"4. Exit\n" +
"Enter choice:\n");
String input = keyboard.nextLine();
int choice = Integer.parseInt(input);
while(choice <= 4|| choice >= 5)
{
if (choice == 4)
{
//System.out.print("Final Balance:"+TotalBal);
System.exit(choice);
}
else if (choice == 3)
{
// System.out.print("Final Balance:"+TotalBal);
}
else if (choice == 1)
{
System.out.print("Enter the deposit amount:$");
String deposit = keyboard.nextLine();
amount = Integer.parseInt(deposit);
TotalBal = balance + amount;
System.out.print("Final Balance:$" + TotalBal);
}
else if (choice == 2)
{
System.out.print("Enter the withdrawal amount:$");
String withdrawal = keyboard.nextLine();
amount = Integer.parseInt(withdrawal);
if (amount <= balance)
{
TotalBal = balance - amount;
System.out.print("Final Balance:$" + TotalBal);
}
else
{
System.out.print("Your withdrawal amount can't be bigger than your current balance");
}
}
else
{
System.out.print("Pick only options 1 - 4.");
}
System.out.print
("\n1. Deposit\n" +
"2. Withdrawal\n" +
"3. View\n" +
"4. Exit\n" +
"Enter choice:\n");
input = keyboard.nextLine();
choice = Integer.parseInt(input);
}
}
}