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

  Design and implement a java program to determine the sum

Design and implement a Java program that will gather a group of floating point numbers and determine the sum and average of the data entered. The program should use separate methods for inputting the data, calculating the sum, calculating the aver..

  A game of tic-tac-toe

A game of tic-tac-toe, two players (one the computer) take turns marking an available cell in a 3 X 3 grid (a two dimensional array) with their respective tokens (either and X or an O). When one player has placed three tokens in a horizontal

  Write code to perform benchmarking of bubble sort algorithm

Write the code to perform the benchmarking of the Bubble Sort algorithm. Your program must include both an iterative and recursive version of the algorithm

  Develop a graphical user interface based java program

Develop a Java program that can communicate with a real SMTP email server for sending emails. TNE 60003 - introduction to network programming, You program should provide a GUI and can successfully send the SMTP commands to the mail server

  Declare a subclass of jpanel called mycolorchooser

Display the current value of each JSlider in the corresponding JTextField. When the user changes the value of the JSlider, the JTextField should be changed accordingly.

  Bull write a blog article for a coding and technical

bull write a blog article for a coding and technical community blog.bull the length of the article is to be between 500

  Practice of using a network of remote servers

What is the name given to the practice of using a network of remote servers hosted on the Internet to store, manage, and process data, rather than a local server or a personal computer.

  Write a java program that finds the temperature

Write a JAVA program that finds the temperature that is the same in both Celsius and Fahrenheit.

  Write a java program to prompts a user to enter information

Write a Java program prompts a user to enter demographic information

  Information from the user and prints a payroll statement

Write a program that accepts the following information from the user and prints a payroll statement

  Create a class called invoice that a hardware store may use

Create a class called Invoice that a hardware store may use to represent an invoice for an item sold at the store.  The class should have four (4) instance variables: part number : string and part description : string (what is the item)

  Write a generic class

Write a generic class (using Java generics) called Pair that stores two values of the generic type.  It should have a constructor to set them, two methods getfirst() and getsecond() to retrieve them.

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