Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Programmers often develop different types of accounts to provide access to a program for a variety of users. The structure of each account is formatted based on the needs of the user and how the program will be used. One type of account is a banking account, which can be used to manage personal financial information. The concrete classes of this type of account contain specific details pertinent to the user and the account, such as the amount of money in the account.

In displaying monetary values, amounts of money are typically written as the amount of dollars and cents with a decimal point. They represent exact quantities. You'll recall that the Java types doubleand floatare inherently inexact. It is always an error, and sometimes a very serious error, to use inexact numeric types for money.

In this assignment you use an abstract class to represent a bank account and concrete classes to represent a checking account and a savings account.

Because the amount of money in these accounts must be exact, you must store all monetary units as intvariables. Your program must keep all monetary values as cents, although the users are not required to enter monetary values in cents. You must create a separate method to convert from dollars and decimal points into an exact number of cents. For example, if the user enters $12.25, this method returns the value 1225.

Create the BankAccountabstract class, with these methods:

- public void deposit(int cents)-Adds money to the account by taking in the number entered by the user and increasing the amount of money in the account by the specified amount (in cents).

- public boolean withdraw(int cents)-Takes money out of the account by taking in the number entered by the user and decreasing the amount of money in the account by the specified amount (in cents). Returns falseif there are insufficient funds in the account.

- public int balance() -Returns the amount of money (in cents) in the account.

- public static boolean transfer(int cents, BankAccountfromAccount, BankAccounttoAccount)-Withdraws money from fromAccountand puts it in toAccount. Returns falseif there are insufficient funds in the fromAccount.

Now create a SavingsAccountclass that extends BankAccount. This new class does not add any new functionality.

Create a CheckingAccountclass that extends BankAccount. Add the following public method:

- public String writeCheck(int cents)-Withdraws the given amount. If there are insufficient funds, this method returns the string INSUFFICIENT FUNDS. If there are sufficient funds, this method returns the dollar amount (for any amount less than one million dollars) as a sequence of uppercase words. For example, ONE HUNDRED SEVEN DOLLARS AND 33 CENTS. When expressing dollars and cents in words, use the word ANDonly before the cents. For example, do not say ONE HUNDRED AND SEVENDOLLARS.

Notes:

- By now you should be used to the idea of TDD-writing the tests first. Continue to do so in this assignment. Perform tests to ensure that, when a method fails because of insufficient funds, the account balances remain unchanged.

- It is good programming style to compose a program from a larger number of small, simple, and relatively independent methods rather than fewer, complex, and tightly-coupled methods. In this assignment, you could put the code for converting dollar amounts into words into the writeCheckmethod, but this would mean:

o You won't ever be able to convert dollars into words without writing a check.
o You won't ever be able to write a check in a different format.
o Your test methods become significantly more complicated.

To avoid these problems, write a separate method (for example, dollarsToWords) that is called from the writeCheckmethod.

- Use the mod (%) and integer division (/) operators; amount%10gives you the last (rightmost) digit of an integer number, while amount/10discards that last digit.

Finally, write a class Bank, containing a mainmethod, to interact with a user who wants to examine balances, perform deposits, withdrawals, and transfers, and write checks.

- Make your program easy to use; write instructions for the program to print out for the user. The instructions tell the user how to perform the various banking operations, as well as how to quit.
- Since the user must enter monetary amounts, you must use a Scannersimilar to the Animal Characteristics Application you previously created.
- Do not require the user to enter monetary amounts in cents. Let the user enter amounts in the following formats:

o12.34
o$12.34
o12.
o12

Your program must have the capability to convert inputs to and from integer cent amounts. Write a method to handle this task. Test this part thoroughly.

- When printing monetary amounts for the user (when he/she asks for the balance of an account), your program must display the amount of money in the account in the following format:

o$12.34

Your program must have the capability to convert outputs from integer cent amounts to dollars. Write a separate method to handle this task.

In your main method, create one SavingsAccount and one CheckingAccount, both with a balance of zero cents. You do not need to write a method to create an account or input any personal account information like name, address, phone number, etc. You do not have to keep track of balances between runs of the program.

When submitting your Application, include screenshots of your program running. Take screenshots demonstrating how your program handles different formats of monetary input. Take screenshots showing two deposits into each of the two accounts, one withdrawal from each of the accounts, one attempt to withdraw more money than one of the accounts contains, and one transfer from one account to the other. Take screenshots showing the balances of each account after each of these transactions. Include screenshots of your program being tested with JUnit.

Save your NetBeans Project and screen shots of the working program as a ".zip" file.

Java, Programming

  • Category:- Java
  • Reference No.:- M91964654
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Java

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As