Advertisement
Guest User

Untitled

a guest
Oct 7th, 2018
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.  
  10.         int n = Integer.parseInt(scanner.nextLine());
  11.         int counter = 0;
  12.         double balance = 0.0;
  13.         while (counter < n) {
  14.             double amount = Double.parseDouble(scanner.nextLine());
  15.             if (amount < 0) {
  16.                 System.out.println("Invalid operation!");
  17.                 break;
  18.  
  19.             } else {
  20.                 balance += amount;
  21.                 System.out.printf("Increase: %.2f%n", amount);
  22.             }
  23.             counter++;
  24.  
  25.         }
  26.         System.out.printf("Total: %.2f%n", balance);
  27.  
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement