ATM Balance Inquiry

This program checks and prints account balance.

Problem Statement

Write a Java program that prints account balance if requested.

Source Code

1 public class ATMBalance {
2 public static void main(String[] args) {
3 double balance = 5000;
4 int choice = 1;
5 if(choice == 1) {
6 System.out.println("Balance: " + balance + " - Eduinq");
7 } else {
8 System.out.println("Invalid choice - Eduinq");
9 }
10 }
11 }

Program Output

Balance: 5000.0 - Eduinq

Explanation

The program uses an if-else ladder to simulate ATM balance inquiry. If the choice equals 1, it prints the balance. Otherwise, it prints invalid choice. This demonstrates how simple conditional checks can simulate real-world banking operations. Shows how ATM balance inquiry can be implemented using if-else ladder.

Quick Links to Explore