Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ComputerScience;
- import java.util.Scanner;
- public class fundsWhile {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.println("How much money do you have in the account?");
- double account = input.nextDouble();
- double withdraw = 0;
- double withdrawTotal = 0;
- boolean stay = true;
- while (stay != false) {
- System.out.println("How much do you want to withdraw?");
- withdraw = input.nextDouble();
- if (account - withdraw > 0) {
- withdrawTotal = withdrawTotal + withdraw;
- account = account - withdraw;
- System.out.println("The total withdraw amount is: $" + withdrawTotal + " and you have $" + account + " left in your account");
- } else {
- System.out.println("You cannot withdraw $" + withdraw + " from the account.");
- System.out.println("The total withdraw amount is: $" + withdrawTotal);
- stay = false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement