Advertisement
desislava_topuzakova

Untitled

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