Advertisement
Kancho

Deposits

Feb 2nd, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Number_Scope {
  4. public static void main(String[] args) {
  5.  
  6. Scanner keyboard = new Scanner(System.in);
  7. System.out.print(" Enter initial balance: ");
  8. double balance = keyboard.nextDouble();
  9. System.out.print(" Enter number of deposits: ");
  10. int n = keyboard.nextInt();
  11. int counter = 1;
  12. while (counter <= n) {
  13. System.out.print("Enter sum lv.: ");
  14. double sum = keyboard.nextDouble();
  15. if (sum <= 0) {
  16. System.out.printf("Invalid operation!%nIncrease = %.2f:%nBalance %.2f:%n",sum,balance);
  17. break;
  18. }
  19. balance = balance + sum;
  20. System.out.printf("Increase = %.2f lv.%nBalance = %.2f lv.%n",sum, balance);
  21. counter++;
  22. }
  23. System.out.printf("Total %.2f lv.", balance);
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement