
: i need to do a program like this:
Automatic Teller Machine [B] Balance [D] Deposit [W] Withdrawal [Q] Quit select you OPtions:
once i have chosen an option then i should proceed here
if i choose b:
YOur Balance is __
if i chose D:
Enter you deposit amount:
if i choose W:
Enter the Withdrawal amount:
every after each of the choices a window like this should come out:
Would you Like to generate bank slip? YES NO
if yes: for balance:
BALANCE INQUIRY AMOUNT BALANCE:
for deposit: DEPOSIT AMOUNT:_ printing book slip:
for withdrawal: your withdrwal amount:
if no: it will return to: Would you like another transaction?
thats the problem. I dont know how to start this program because i am a beginner, and aside from that i am really eager to learn java please help me with the codes and please explain to me how it works. i only need to use if else statements and do while beacause it is the lesson we are in to, please help m,e

import java.util.*;
class ATM{
static Scanner input = new Scanner(System.in);
String name, actype;
int accNo, bal, amt;
ATM(String name, int accNo, String actype, int bal) {
this.name = name;
this.accNo = accNo;
this.actype = actype;
this.bal = bal;
}
int deposit(){
System.out.print("Enter amount to deposit:");
amt = input.nextInt();
if (amt < 0) {
System.out.println("Invalid Amount");
return 1;
}
bal = bal + amt;
return 0;
}
int withdraw(){
System.out.println("Your Balance=" + bal);
System.out.print("Enter amount to withdraw:");
amt = input.nextInt();
if (bal < amt) {
System.out.println("Not sufficient balance.");
return 1;
}
if(amt < 0) {
System.out.println("Invalid Amount");
return 1;
}
bal = bal - amt;
return 0;
}
void display(){
System.out.println("Name:" + name);
System.out.println("Account No:" + accNo);
System.out.println("Balance:" + bal);
}
void dbal() {
System.out.println("Balance:" + bal);
}
public static void main(String args[]){
System.out.println("Enter your Name: ");
String nn = input.nextLine();
System.out.println("Enter Account Number: ");
int num = input.nextInt();
System.out.println("Enter Account Type: ");
String type = input.next();
System.out.println("Enter Initial Balance: ");
int bal = input.nextInt();
ATM b1 = new ATM(nn, num, type, bal);
int menu;
System.out.println("Menu");
System.out.println("B. Balance");
System.out.println("D. Deposit");
System.out.println("W. Withdraw ");
System.out.println("Q. Quit");
boolean quit = false;
do{
System.out.print("Please enter your choice: ");
menu = input.nextInt();
switch(menu) {
case 1:
b1.display();
break;
case 2:
b1.deposit();
break;
case 3:
b1.withdraw();
break;
case 4:
quit = true;
break;
}
}
while (!quit);
}
}

import java.util.*;
class ATM{
static Scanner input = new Scanner(System.in);
String name, actype;
int accNo, bal, amt;
ATM(String name, int accNo, String actype, int bal) {
this.name = name;
this.accNo = accNo;
this.actype = actype;
this.bal = bal;
}
int deposit(){
System.out.print("Enter amount to deposit:");
amt = input.nextInt();
if (amt < 0) {
System.out.println("Invalid Amount");
return 1;
}
bal = bal + amt;
return 0;
}
int withdraw(){
System.out.println("Your Balance=" + bal);
System.out.print("Enter amount to withdraw:");
amt = input.nextInt();
if (bal < amt) {
System.out.println("Not sufficient balance.");
return 1;
}
if(amt < 0) {
System.out.println("Invalid Amount");
return 1;
}
bal = bal - amt;
return 0;
}
void display(){
System.out.println("Name:" + name);
System.out.println("Account No:" + accNo);
System.out.println("Balance:" + bal);
}
void dbal() {
System.out.println("Balance:" + bal);
}
public static void main(String args[]){
System.out.println("Enter your Name: ");
String nn = input.nextLine();
System.out.println("Enter Account Number: ");
int num = input.nextInt();
System.out.println("Enter Account Type: ");
String type = input.next();
System.out.println("Enter Initial Balance: ");
int bal = input.nextInt();
ATM b1 = new ATM(nn, num, type, bal);
String menu;
System.out.println("Menu");
System.out.println("B. Balance");
System.out.println("D. Deposit");
System.out.println("W. Withdraw ");
System.out.println("Q. Quit");
boolean quit = false;
do{
System.out.print("Please enter your choice: ");
menu = input.next();
char choice=menu.charAt(0);
switch(choice) {
case 'B':
b1.display();
break;
case 'D':
b1.deposit();
break;
case 'W':
b1.withdraw();
break;
case 'Q':
quit = true;
break;
}
}
while (!quit);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.