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