I am writing this program that gives the user options. When I choose "make a deposit" and "then see balance" the amount entered is not accumulating and printing as Ending balance. How can I do that? how can I acculmualte all the money entered ? a lot of times and them print whenever I ask for?  I copied it here and attached pictures      import java.util.*; public class AccountTransactionAssignment {   public static void main(String[] args) { Scanner console= new Scanner(System.in);   welcomeMenu(); differentOperations();   } public static void displayMenu() { System.out.println(); System.out.println("Enter your choice: "); System.out.println("\tB See Balance"); System.out.println("\tD Make Deposit"); System.out.println("\tW Make a Withdrawal"); System.out.println("\tQ Quit "); } public static char getInput() { Scanner console= new Scanner(System.in); String temp= console.next().toUpperCase(); returntemp.charAt(0); }   public static void welcomeMenu() { Scanner console= new Scanner(System.in); System.out.println("Hello! This program is going to help you to keep track " + "of your account balance.\n"); System.out.println("Would you like to continue? Enter yes.\nNo help needed " + "at this time? Enter no.\n");     } public static void differentOperations() { Scanner console= new Scanner(System.in); String option= console.next(); if(option.equalsIgnoreCase("no")){ System.out.println("You are exiting this program, see you later!"); } else { System.out.println("Lets get started!");    displayMenu(); char choiceEntered= getInput();   double endingBalance= 0; double balance= 0; double amount= 0;   while(choiceEntered != 'Q') {   endingBalance= balance; if(choiceEntered == 'B') { System.out.println("Your ending balance is: "+balance);     } else if(choiceEntered == 'D') { System.out.println("Make a deposit"); System.out.println("How much do you want to deposit? "); amount= console.nextDouble(); if(amount > 0) { endingBalance += amount; } else { System.out.println("Invalid input, try again."); }       } else if(choiceEntered== 'W') { System.out.println("Make a withdrawal"); } else { System.out.println("Invalid input. Please try again!"); } displayMenu(); choiceEntered= getInput();   }   System.out.println("You are exiting this program. See you later!");   }       }       }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I am writing this program that gives the user options. When I choose "make a deposit" and "then see balance" the amount entered is not accumulating and printing as Ending balance. How can I do that? how can I acculmualte all the money entered ? a lot of times and them print whenever I ask for? 

I copied it here and attached pictures 

 

 

import java.util.*;

public class AccountTransactionAssignment {

 

public static void main(String[] args) {

Scanner console= new Scanner(System.in);

 

welcomeMenu();

differentOperations();

 

}

public static void displayMenu() {

System.out.println();

System.out.println("Enter your choice: ");

System.out.println("\tB See Balance");

System.out.println("\tD Make Deposit");

System.out.println("\tW Make a Withdrawal");

System.out.println("\tQ Quit ");

}

public static char getInput() {

Scanner console= new Scanner(System.in);

String temp= console.next().toUpperCase();

returntemp.charAt(0);

}

 

public static void welcomeMenu() {

Scanner console= new Scanner(System.in);

System.out.println("Hello! This program is going to help you to keep track "

+ "of your account balance.\n");

System.out.println("Would you like to continue? Enter yes.\nNo help needed "

+ "at this time? Enter no.\n");

 

 

}

public static void differentOperations() {

Scanner console= new Scanner(System.in);

String option= console.next();

if(option.equalsIgnoreCase("no")){

System.out.println("You are exiting this program, see you later!");

}

else {

System.out.println("Lets get started!");   

displayMenu();

char choiceEntered= getInput();

 

double endingBalance= 0;

double balance= 0;

double amount= 0;

 

while(choiceEntered != 'Q') {

 

endingBalance= balance;

if(choiceEntered == 'B') {

System.out.println("Your ending balance is: "+balance);

 

 

}

else if(choiceEntered == 'D') {

System.out.println("Make a deposit");

System.out.println("How much do you want to deposit? ");

amount= console.nextDouble();

if(amount > 0) {

endingBalance += amount;

}

else {

System.out.println("Invalid input, try again.");

}

 

 

 

}

else if(choiceEntered== 'W') {

System.out.println("Make a withdrawal");

}

else {

System.out.println("Invalid input. Please try again!");

}

displayMenu();

choiceEntered= getInput();

 

}

 

System.out.println("You are exiting this program. See you later!");

 

}

 

 

 

}

 

 

 

}

 

Expert Solution
steps

Step by step

Solved in 6 steps with 2 images

Blurred answer
Knowledge Booster
Software products
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education