Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String input = scanner.nextLine();
- double sum = 0.0;
- while (!input.equals("NoMoreMoney")) {
- double currentNum = Double.parseDouble(input); // not (scanner.nextLine()) !!! ???
- if (currentNum < 0) {
- System.out.println("Invalid operation!");
- break;
- }
- System.out.printf("Increase: %.2f%n", currentNum);
- sum += currentNum;
- input = scanner.nextLine();
- }
- System.out.printf("Total: %.2f", sum);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement