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