Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. package ComputerScience;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class fundsWhile {
  6.  
  7. public static void main(String[] args) {
  8. Scanner input = new Scanner(System.in);
  9. System.out.println("How much money do you have in the account?");
  10. double account = input.nextDouble();
  11. double withdraw = 0;
  12. double withdrawTotal = 0;
  13. boolean stay = true;
  14. while (stay != false) {
  15. System.out.println("How much do you want to withdraw?");
  16. withdraw = input.nextDouble();
  17. if (account - withdraw > 0) {
  18. withdrawTotal = withdrawTotal + withdraw;
  19. account = account - withdraw;
  20. System.out.println("The total withdraw amount is: $" + withdrawTotal + " and you have $" + account + " left in your account");
  21. } else {
  22. System.out.println("You cannot withdraw $" + withdraw + " from the account.");
  23. System.out.println("The total withdraw amount is: $" + withdrawTotal);
  24. stay = false;
  25. }
  26.  
  27.  
  28. }
  29.  
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement