The public methods of the bankaccount class

Assignment Help Basic Computer Science
Reference no: EM13969549

The objectives of this assignment are to:

  • Be able to write a Java class definition with amainmethod that creates and uses instances (Objects) of another class.
  • Be able to declare Java variables that refer to a class data type, in this project theBankAccountclass, and are initialized by instances of that class (by calls to the class constructor).
  • Be able to use the public methods, such asgetandsetmethods of an Object to read and write values stored in that Object.
  • Understand that the data stored in an Object can only be accessed by the public methods defined in that Object's class definition.

This assignment is based on your use of the public methods of the BankAccount class, provided below, to modify the checking and savings accounts of two individuals: Nick and Carol. Your job is to create a BankingDriver class and write statements in its main method that carry out the actions specified in the Project Requirements list below. Your statements must use the public methods provided by the BankAccount class. You will submit the BankingDriver.java code as your solution to this problem.

The BankAccount class definition:

/* This class encapsulates data for checking and savings acounts 
and provides an API that allows deposits and withdrawals to be made
to these accounts.
*/
public class BankAccount{
      private String name;
      private int checkMoney;
      private int saveMoney;

       public BankAccount(String who, int checking, int saving){
         name = who;
         checkMoney = checking;
         saveMoney = saving;
      }

       public String getAccountName(){
         return name;
       }

       public int getCheckMoney(){
         return checkMoney;
       }

       public int getSaveMoney(){
         return saveMoney;
       }

       public void makeCheckingDeposit(int amt){
           checkMoney = checkMoney + amt;
       }

       public void makeSavingsDeposit(int amt){
         saveMoney = saveMoney + amt;
       }
       
       public void makeCheckingWithdrawal(int amt){
        if(checkMoney >= amt)
         checkMoney = checkMoney - amt;
       }
       
       public void makeSavingsWithdrawal(int amt){
        if(saveMoney >= amt)
         saveMoney = saveMoney - amt;
       }
       
       //prints name and both account balances to the console
       public void printReport() {
         System.out.println(name + " checking: " + checkMoney + " savings: " + saveMoney);
       }
   }

Project Requirements

This is what your code must do:

  1. Create aBankAccountobject callednicksAcctsuch that Nick initially has $450 in his checking account, and $550 in his savings account.
  2. Create aBankAccountobject calledcarolsAcctsuch that Carol initially has $600 in her checking account, and $700 in her savings account.
  3. Print out a report of the checking and savings information on both Nick's and Carol's accounts using theprintReportmethod in theBankAccountclass. The output should look like this:Nick checking: 450 savings: 550
    Carol checking: 600 savings: 700
  4. Print out the sum of all money in both Nick's and Carol's savings and checking accounts. That is, the sum of Nick's savings and checking added to the sum of Carol's savings and checking. (you must use methods from theBankAccountclass here to obtain the the various amounts that contribute to the final total). The output should look like this:
    Total money in all accounts: $2300
  5. Deposit $100 to Nick's checking account using the appropriateBankAccountclass method.
  6. Print out a report of the checking and savings information onNick's account onlyusing the appropriate method in theBankAccountclass (same method used in step 3).
  7. In a series of statements, move all of the money in Nick's accounts - both checking and savings - to Carol's checking account. This should leave Nick with no money at the end- i.e. both of his accounts have 0 money. There are several ways this may be accomplished. A suggestion is to use one or more intermediate variables to hold the values from Nick's account, then deposit that value to Carol's checking account. Note: you must get the values from Nick's account by calling the methods defined in theBankAccountclass.
  8. Print out a report of the checking and savings information on both Nick's and Carol's accounts using the appropriate method in theBankAccountclass. (same as step 3).

The correct output on the examples above would be: 
Nick checking: 450 savings: 550
Carol checking: 600 savings: 700
Total money in all accounts: $2300
Nick checking: 550 savings: 550
Nick checking: 0 savings: 0
Carol checking: 1700 savings: 700

Remember- You must use the public methods of the BankAccount class in your code to achieve the steps listed above to get full credit. Pretend theBankingDriver does not know the amounts in the two BankAccount objects and has to use their public methods to get these values.

Reference no: EM13969549

Questions Cloud

Number of letters in front of terry : On Thursday, Daisy, Lookout Ltd's secretary, puts a number of letters in front of Terry for his sig- nature. Terry is busy talking to the workshop manager at the time and signs his name without reading each one. He has now discovered that one of t..
Explain lzss compression and what are the improvements of : Explain LZSS compression and what are the improvements of LZSS on LZ77
Methods of user-based and user-controlled navigation : Discuss different methods of user-based and user-controlled navigation. Define five common types of links used in a navigation system.
Prepare a case study on turkell stud mill case : Prepare a case study on "Turkell Stud Mill Case". Analysis Coherent flow; adequate research; presentation of the key issues and concerns related to the situation.
The public methods of the bankaccount class : The public methods of the BankAccount class in your code to achieve the steps listed above to get full credit. Pretend theBankingDriver does not know the amounts in the two BankAccount objects and has to use their public methods to get these values.
Write the maxterm expansion for f : A combinational switching circuit has four inputs and one output as shown. F = 0 iff three or four of the inputs are 1.    a.  Write the maxterm expansion for F.
Customers on the afternoon of the party : She sets up a home catering business and immediately agrees to cater for 100 people attending a 21st birthday party for a price of £300. She insists on £100 deposit. As the day for the party approaches, she finds that she has taken on too much wor..
Semiannual interest payments : Company B issued $3,000,000 of a bond on 1-1-x1. Since the market interest rates were lower than the bond interest rate, the bonds were sold for a premium. The company received $3,200,000 for the bonds with a 20 year life, 10%, semiannual interest pa..
Affect varied locations to different extents : In this course we examine a number of environmental impacts, and some of them may be of particular concern in your local area. Environmental impacts like urban sprawl, air and water pollution, and rapid urban growth (just to name a few) tend to affec..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Create a new table that adds a new column

Create a new table that adds a new column to the l_foods table. Use a row function that will add together the price and the price_increase columns. Name the new column new_price.

  Let the predicate

11. Let the predicate ">" be defined as follows: Let a and b be integers. "a > b" if and only if a = b + k where k is an integer > 0. Using only this definition, prove that ">" is transitive, i.e., if x, y, and z are integers and x > y and y >..

  Identify possible actors and use cases

1. Identify possible actors and use cases involved in Personal Trainer's operations. 2. Create an object relationship diagram for the Personal Trainer information system.

  Similarities between email tracking or news posting tracking

Discuss the differences and similarities between email tracking and news posting tracking.

  Q1 give an overview of the intellectual property law q2

develop a two to four 2-4 page policy in which youq1. provide an overview of intellectual property law.q2. describe who

  Select and describe in detail the evaluation method

Computer class written assignment. select and describe in detail the evaluation method that you plan to use to compare and contrast the 3 options. Write 250 to 300 words.

  State turing machine m that calculates function

State a Turing Machine M that computes the function f: {a, b}* → N, where: f(x) = the unary encoding of max(#a(x), #b(x)).

  Carrying out a big data readiness assessment

The theme of the assignment is the reliability (or unreliability) of Assisted GPS Location Services in smart devices (Smart Phones, Tablets, Smart Cameras, etc.).

  Paper on on the turing and von neumann models

Write a 2 page research paper (excluding the title page) on the Turing and von Neumann models. Compare and contrast each and discuss which model is better and why

  Determine how to set up the server for the future expansion.

Habibi's has a small network of 20 client workstations and a Windows Server 2008. Seven of those workstations are inside the restaurant and are used by the table servers to place customer orders.

  Unix uses many commands in its operating system

Question 1: UNIX uses many commands in its operating system. Research on the web at least 2 more commands describe their function and discuss similar commands in Windows operating system.

  Write functions and steps for various window applications

Write down the functions and steps involved in various window applications. What is mail merge? Enumerate the steps involved in mail merge.

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