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