Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(in java programming language ) 1. Implement all the methods of the following class: class Person { public Person() { ... } public Person(String givenName,

(in java programming language )

1. Implement all the methods of the following class:

class Person { public Person() { ... }

public Person(String givenName, int yearOfBirth) { ... }

public String getName() { ... }

public String changeName(String name) { ... }

public int getAgeInYears(int currentYear) { ... }

private String name; private int birthdayYear; }

Write a small test program that creates and works with objects of class Person as well.

-------------------------------------

2. Implement a class Account. An account has

a balance,

functions to add

and withdraw money,

and a function to inquire the current balance.

Pass a value into a constructor to set an initial balance.

If no value is passed the initial balance should be set to $0.

Charge a $5 penalty if an attempt is made to withdraw more money than available in the account. Enhance the Account class to compute interest on the current balance.

---------------------------------------------------

3. Implement a class Bank.

This bank has two objects

checking and savings

of the type Account that was developed in the preceding exercise.

Implement four instance methods:

deposit(double amount, String account)

withdraw(double amount, String account)

transfer(double amount, String account)

printBalances()

Here the account string is "S" or "C". For the deposit or withdrawal, it indicates which account is affected. For a transfer it indicates the account from which the money is taken; the money is automatically transferred to the other account.

---------------------------------------

4. Define a class Country that stores the

name of the country,

its population,

and its area.

Using that class, write a test program that creates a few countries and stores them in an array and then prints The country with the largest area

The country with the largest population

The country with the largest population density (people per square mile)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

What is management growth? What are its factors

Answered: 1 week ago

Question

5. Have you stressed the topics relevance to your audience?

Answered: 1 week ago