Objectives The objectives of this programming assignment are



Objectives: The objectives of this programming assignment are to understand the following concepts:

• Creating class

• Creating subclasses

• Inheriting data and methods

• Overloading methods

• Overriding methods

• Invoking constructor of the superclass

• Use of the keyword super

Exercise:
1. Create an Account class that has the following data and behavior

• An integer data field – accountId, i.e., the account id (default value is 0).

• A double data field – balance that stores the current balance for the account (default value is 0).

• A double data field - annualInterestRate (default value is 0).

• A Date data field - dateCreated that stores the date when the account was created.

• A no-arg constructor that creates a default account.

• A 3-arg constructor that creates an account using a specified account ID, balance, and

• annual interest rate.

• The accessor(get) and mutator(set) methods for accountId, balance, annualInterestRate.

• The accessor(get) method for dateCreated.

• A method named getMonthlyInterest() that returns the monthly interest.

• A method named withdraw that withdraws a specified amount from the account.

• Create two overloaded deposit methods such that one of them takes an integer value as the input parameter and the second one takes a double value as the input parameter.

2. Create two subclasses for Checking and Savings account that extend your Account class from previous assignment. Implement the following in these 2 subclasses:

• A Checking account has an overdraft limit (of $5,000), but a Savings account cannot be overdrawn. Override the withdraw method in these subclasses to take care of the overdraft restrictions.
• All data and methods are inherited from Account class.

• Create constructors for both Checking and Savings account. These constructors should invoke the constructors of their superclass

3. Write a test program (class named TestAccount) that does the following:

• Creates 2 objects - a Saving Account and a Checking Account. Get user inputs for account information that is needed to create these 2 objects.

• Get user input for an amount to be withdrawn from the Checking Account (for example, $2,500) and an amount to be deposited to the Checking Account (for example, $3,000). Make sure the overdraft restrictions work.

• Similarly, withdraw and deposit from and into the Saving Account also.

• Finally, print the account information for both the Checking and Saving accounts (i.e., print the current balance (after withdrawal and deposit), the monthly interest, and the date when these two accounts were created).

Solution

Java defines several bitwise operators, which can be applied to the integer sorts, long, int, short, char, and byte.

Bitwise operator works on bits and performs bit-via-bit operation. count on if a = 60 and b = 13; now in binary format they\'ll be as follows

a = 0011 1100

b = 0000 1101

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

a&b = 0000 1100

athe subsequent desk lists the bitwise operators

anticipate integer variable A holds 60 and variable B holds thirteen then

show Examples

Operator   Description   example
& (bitwise and)   Binary AND Operator copies a bit to the end result if it exists in each operands.   (A & B) will supply 12 that is 0000 1100
a chunk if it exists in either B) will supply 61 that is 0011 1101
^ (bitwise XOR)   Binary XOR Operator copies the bit if it\'s far set in one operand but no longer both.   (A ^ B) will deliver forty nine that\'s 0011 0001
~ (bitwise compliment)   Binary Ones supplement Operator is unary and has the effect of \'flipping\' bits.   (~A ) will supply -61 which is 1100 0011 in 2\'s supplement shape because of a signed binary range.
<< (left shift)   Binary Left Shift Operator. The left operands fee is moved left by using the variety of bits distinct by means of the proper operand.   A << 2 will give 240 which is 1111 0000
>> (proper shift)   Binary right Shift Operator. The left operands fee is moved proper by using the number of bits detailed through the right operand.   A >> 2 will give 15 which is 1111
>>> (zero fill right shift)   Shift proper 0 fill operator. The left operands price is moved proper by the wide variety of bits detailed by means of the right operand and shifted values are filled up with zeros.   

 Objectives: The objectives of this programming assignment are to understand the following concepts: • Creating class • Creating subclasses • Inheriting data an
 Objectives: The objectives of this programming assignment are to understand the following concepts: • Creating class • Creating subclasses • Inheriting data an

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site