Write a separate method to handle this task

Assignment Help JAVA Programming
Reference no: EM131208649

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.

Verified Expert

The program was to write classes for a banking account to perform operations like deposit,withdrawal,transfer etc.Here BankingAccount is an abstract class while SavingsAccount and CheckingAccount which extends from it are concrete classes.Junit unit test cases are also written to perform unit test .The program also requires to convert amount in digits to words for writeCheque method of CheckingAccount.Conversion from dollars to cents and cents to dollars are also performed.

Reference no: EM131208649

Questions Cloud

Pyramid of numbers is not always pyramid shape : A pyramid of numbers is not always pyramid shape explain why
Determining the compounded daily : How much must you deposit today into an account with an APR of 4% compounded daily in order to have a $120,000 college fund in 15 years? Please show the work.
Describe the rationale for selecting the best strategy : Describe the rationale for selecting the best strategy. Provide a summary or conclusion about this experience or assignment and how you may deal with conflict more effectively in the future.
Determine the induced voltage and the power angle of motor : The per-phase impedance of a 600-V, three-phase, Y-connected synchronous motor is 5 + j50 Ω. The motor takes 24 kW at a leading power factor of 0.707. Determine the induced voltage and the power angle of the motor.
Write a separate method to handle this task : 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 - Your program must have the capability to convert inputs to and from integer cent amounts. Write a..
Find the armature current : A 10-hp, 230-V, 60 Hz, three-phase wye-connected synchronous motor delivers full load at a power factor of 0.8 leading. The synchronous reactance is 6 Ω, the rotational loss is 230 W, and the field loss is 50 W
How many fields will be have : If max divides his land into square field's that are 1/4 mile long and 1/4 mile wide, how many fields will be have?
Determine load current and transformer secondary voltage : Determine Load current and transformer secondary voltage when load V=235V. - Transformer primary voltage and current.
How you can meet the needs of diverse families : Include how you can meet the needs of diverse families or those that have recently moved to the area. Create a family involvement plan by choosing one or two strategies from at least three categories listed.

Reviews

len1208649

9/16/2016 3:54:32 AM

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.

Write a Review

JAVA Programming Questions & Answers

  Number of columns in the second matrix

Write a method multiply() that takes two square matrices of the same dimension as arguments and produces their product(another square matrix ofthat samedimension). Extra credit: Make your program work whenever the number of rows in the first matri..

  Write a version of sumpairs

Write a version of sumPairs  that sums each component of the pairs separately, returning a pair consisting of the sum of the first components and the sum of the second components. So basically [(3,1)(10,3)] would return (13,4).

  Calculate the new date by adding a fixed number of days

What I have done is the "ExtendedDate.java", which improved the "data.java" that the program will firstly check if the date input from users is valid then store it with the setDate method.

  Projectyou will create a secure parts inventory catalog

projectyou will create a secure parts inventory catalog system using model 2 architecture. the application will require

  Explain java-oriented microprocessors presented by sun

Research the latest Java-oriented microprocessors presented by Sun. In what ways are they optimized to implement Java programs?

  Evaluate the rtas resource requirements

Design and implement a set of classes and interfaces and use them to evaluate the RTA's resource requirements.

  Determine the number of quarters

You have an amount of change (such as 41 cents or 72 cents) and you want to figure out how many quarters, dimes, nickels and pennies that is. Your change will always be an integer value between 0 and 99.

  Create three classes for a customer

a travel manager and have a job of buying a travel package for a customer. You must create three classes for this programming challenge: Customer, Ticket, and TravelManagerDemo.

  Which is the best character high value

When updating a master file with data from a transaction file, what should happen for an addition record when a match is found in the master file?

  Create an algorithm in java

Create an algorithm in java which will provide the Dijkstras shortest path in a graph provided by the user - The output should display the shortest path.

  Morgellons disease is delusional

Why do some scientists say that Morgellons disease is delusional? When there have been fibers extracted from patients that cannot be identified? Isn't that physical proof that something is affecting these people physically?

  Delete a random element from an arraylist

Elements in an ArrayList and picking one at random to remove. Unfortunately, this slow, since deleting a random element from an ArrayList is slow because of all the shifting. For this question, you should modify the poll()method so that it runs in..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd