Object-Oriented Programming with Java, part I – Exercise 72.1

This program uses the object account to create a new account with $100, add $20 and then print the result.

My Code

import java.util.Scanner;

public class Accounts {

    public static void main(String[] args) {
        // Code in Account.Java should not be touched!
        // write your code here
        Account bartosAccount = new Account("Barto's account",100.00);
        bartosAccount.deposit(20);
        System.out.println(bartosAccount);
    }

}

Model Code

import java.util.Scanner;

 

public class Accounts {

 

    public static void main(String[] args) {

        // Code in Account.Java should not be touched!

        // write your code here

        Account account = new Account("Barto's account", 100.0);

 

        account.deposit(20);

        System.out.println(account);

    }

 

}

 

Comments

There are some differences. The major one being that I have called the new account bartosAccount whereas they have just called it account.

Leave a comment