Advertisement
Stelios_Gakis

Seminar_2/Task_4

Sep 26th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.43 KB | None | 0 0
  1. package Seminar_2;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Task_4 {
  6.  
  7.     private static final Scanner in = new Scanner(System.in);
  8.     private double balance;
  9.     private double finalFreeMoney;
  10.  
  11.     public static void main(String[] args) {
  12.  
  13.         Task_4 myApp = new Task_4();
  14.  
  15.         System.out.print("Please, enter your balance : ");
  16.         myApp.balance = in.nextDouble();
  17.         for (int i = 0; i < 10; i++) {
  18.             int depositsLeft = 9 - i;
  19.             double money = myApp.addingStep();
  20.             if (i < 8) {
  21.                 System.out.printf("Your new balance is %.2f SEK%n", money);
  22.                 System.out.printf("You have %d deposits left.%n", depositsLeft);
  23.             } else if ( i == 8 ){
  24.                 System.out.printf("Your new balance is %.2f SEK%n", money);
  25.                 System.out.printf("You have %d deposit left.%n", depositsLeft);
  26.             } else {
  27.                 System.out.printf("Your final balance is %.2f SEK%n", money);
  28.             }
  29.         }
  30.     }
  31.  
  32.     private double addingStep() {
  33.         System.out.printf("--- --- ---%nPlease enter the amount you would like to deposit : ");
  34.         double deposit = in.nextDouble();
  35.         finalFreeMoney = freeMoney(deposit);
  36.         balance += finalFreeMoney;
  37.         return balance;
  38.     }
  39.  
  40.     private double freeMoney(double money) {
  41.         finalFreeMoney = money + (money * 0.1);
  42.         return finalFreeMoney;
  43.     }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement