Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Seminar_1;
- import java.util.Scanner;
- public class Task_1 {
- public static void main(String [] args){
- int move, balance = 0, d = 0, w = 0;
- Scanner input = new Scanner (System.in);
- System.out.println("Welcome to our bank!");
- for (int i = 0; i < 10; i++) {
- System.out.println("--- --- ---");
- System.out.println("Current balance:" + balance);
- System.out.println("--- --- ---");
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- System.out.println("Enter a deposit or withdraw (>0 = deposit, <0 withdraw)");
- move = input.nextInt();
- if (move > 0) {
- balance += move;
- d += 1;
- }
- else if (move < 0) {
- balance += move;
- w += 1;
- }
- else {
- System.out.println("You can not deposit/withdraw 0 SEK");
- i -= 1;
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- System.out.printf("# of Deposits = %d%n# of Withdraws = %d%nFinal balance = %d", d, w, balance);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement