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