Advertisement
Guest User

Untitled

a guest
Apr 1st, 2022
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class AccountBalance {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. double total = 0;
  7.  
  8. String input = scanner.nextLine();
  9.  
  10. while (!input.equals("NoMoreMoney")) {
  11. double deposit = Double.parseDouble(input);
  12.  
  13. if (deposit < 0) {
  14. System.out.println("Invalid operation!");
  15. break;
  16. } else {
  17. System.out.printf("Increase: %.2f%n", deposit);
  18. }
  19. total += deposit;
  20.  
  21. input = scanner.nextLine();
  22. }
  23.  
  24. System.out.printf("Total: %.2f", total);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement