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

  All sales transactions and viewing parties

Display the details of the best junior sales agent (i.e. ID, Name, DOB) who is under the age of 25, in terms of their average negotiation profit (consider the askingPrice and agreedPrice attributes). The agent returned must have at least three sal..

  Html5 can validate weather an email address true or false

HTML5 can validate weather an email address entered by the user actually exists. True or False

  Distributed.net is an organization that coordinates research

Distributed.net is an organization that coordinates research on distributed computing applications. People and organizations can join Distributed.net and contribute idle computing power to ongoing research projects that require or use massively..

  Describe how project portfolio management

Describe how project portfolio management is used by IT departments

  What u think about the article database fight funding cuts

What u think about the article Database fight funding cuts

  Write c program to find the number of occurrences of a word

Write C program to find the number of occurrences of a word from a file given in a specified path. For this you need to give your text file path with some text, and specify the word for which you need to find the frequency.

  Find a simplified expression for function

find a simplified expression for F = A?BC?D + A?B?D + A?CD + ABD + ABC - Assuming that the inputs ABCD = 0101, BCD = 1001, ABCD = 1011 never occur,

  The main goal of any business communication

The main goal of any business communication is to determine what message needs to be delivered, and how to deliver it clearly and concisely to the intended audience.

  Development of enterprise architecture-existing it resources

Discuss what concepts are important to share during this presentation in particular. Also discuss, in general, the relationship between development of enterprise architecture and existing IT resources and processes.

  What information is required to setup a new account

What information is required to setup a new account, what category information is collected by the site

  Why is it necessary to include both wmfc and mfc

Why is it necessary to include both WMFC and MFC in the logic expression for Counter_enable given in Section 5.6.2?

  Write a bash shell script

Write a bash shell script that asks the user for a number and then tells the user whether the number is a prime number or not.  Need the answer to use /tmp/primes, a file containing the first million known primes.

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