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