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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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