stoyanoff

AccountBalance_05_V2

Jul 6th, 2020
1,176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class AccountBalance_05_V2 {
  4.     public static void main(String[] args) {
  5.         Scanner myScan = new Scanner(System.in);
  6.  
  7.         double balance = 0;
  8.         double totalBalance = 0;
  9.         String input = myScan.nextLine();
  10.  
  11.         while (!input.equals("NoMoreMoney")){
  12.  
  13.             balance = Double.parseDouble(input);
  14.             if(balance > 0) {
  15.                 System.out.printf("Increase: %.2f%n", balance);
  16.                 totalBalance += balance;
  17.             } else {
  18.                 System.out.println("Invalid operation!");
  19.                 break;
  20.             }
  21.             input = myScan.nextLine();
  22.  
  23.  
  24.         }
  25.         System.out.printf("Total: %.2f", totalBalance);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment