How do I write a program for an account balancer. I have decided to use a sentin
ID: 3649161 • Letter: H
Question
How do I write a program for an account balancer. I have decided to use a sentinal value of 9999 to terminate the problem when entered into my while loop which will terminate all deposits that I make, but have to use a second sentinal value, I choose 8888 which will display the current account balance with a message that reads "The current balance is ####", or till i stop inputing numbers and input 8888. I must also note that any negative number is a check that reduces the account balance along with detucting a $10 fee from the account. All positive numbers are deposits to add to the account balanceExplanation / Answer
Use a boolean variable to check when your while loop ends. Inside the While loop u can use if else statements for 8888 and positive numbers and negative numbers. Heres the psuedo code. I have also written the code for java in comments. While(boolean is true) // check == true ; { Take the input and assign it to input // input = Integer,parseInt(br.readLine()) here // br is Buffered Reader. if(input >=0) { if (input == 8888) { print the current value ; // in Java u can use System.out.println("The current balance is " + count); } else if(input == 9999) { Set the boolean value to false; // so that the loop ends next time. check = false } else { add to the account balance; // count += input; } } else if (inputRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.