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