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