Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]) {
- java.util.Scanner scanner = new java.util.Scanner(System.in);
- String input = "";
- double total = 0.0;
- while(true) {
- input = scanner.nextLine();
- if (input.equals("NoMoreMoney")) {
- break;
- }
- else if (Double.parseDouble(input) < 0) {
- System.out.println("Invalid operation!");
- break;
- } else {
- System.out.printf("Increase: %.2f\n",Double.parseDouble(input));
- total += Double.parseDouble(input);
- }
- }
- System.out.printf("Total: %.2f", total);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement