Advertisement
psi_mmobile

Untitled

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