Loading...

Messages

Proposals

Stuck in your homework and missing deadline? Get urgent help in $10/Page with 24 hours deadline

Get Urgent Writing Help In Your Essays, Assignments, Homeworks, Dissertation, Thesis Or Coursework & Achieve A+ Grades.

Privacy Guaranteed - 100% Plagiarism Free Writing - Free Turnitin Report - Professional And Experienced Writers - 24/7 Online Support

Java bank account transfer method

19/11/2021 Client: muhammad11 Deadline: 2 Day

the HW questions are attached in 2 pictures ( 5 ) questions

Ex 7.1

Ex 7.2

Ex. 7.10

Ex 7.12

Ex 7.15

Lab 4: OO Design and Interfaces

Score: 50 pts

I. Student GPA’s

This exercise is based on the requirement analysis and solution design that was discussed in class. The full analysis can be found under the Week 7 -> Materials folder on BlackBoard. You are required to take this design and convert it into Java code. This includes writing the Student class along with its variables and methods. Make sure that you use the proper accessibility modifiers (private & public) such that encapsulation is properly enforced.

After writing the Student class, write another class named StudentData, and add your main function in that class. In the main function, create two objects of the Student class, add four courses for the first student object, and three courses for the second student object. Each added course is associated with a letter grade and a number of credits. Then call the compute_gpa() function to compute the GPA for each student, and print out the GPA for each student, along with his list of courses, grades and credits.

II. Using the Comparable Interface

1. Write a class Compare3 that provides a static method largest. Method largest should take three Comparable parameters and return the largest of the three (so its return type will also be Comparable). Recall that method compareTo is part of the Comparable interface, so largest can use the compareTo method of its parameters to compare them.

2. Write a class Comparisons whose main method tests your largest method above.

· First prompt the user for and read in three strings, use your largest method to find the largest of the three strings, and print it out. (It’s easiest to put the call to largest directly in the call to println.) Note that since largest is a static method, you will call it through its class name, e.g., Compare3.largest(val1, val2, val3).

· Add code to also prompt the user for three integers and try to use your largest method to find the largest of the three integers. Does this work? If it does, it’s thanks to autoboxing, which is Java 1.5’s automatic conversion of ints to Integers. You may have to use the -source 1.5 compiler option for this to work.

III. A Flexible Account Class

File Account.java contains a definition for a simple bank account class with methods to withdraw, deposit, get the balance and account number, and return a String representation. Note that the constructor for this class creates a random account number. Save this class to your directory and study it to see how it works. Then modify it as follows:

1. Overload the constructor as follows:

· public Account (double initBal, String owner, long number) - initializes the balance, owner, and account number as specified

· public Account (double initBal, String owner) - initializes the balance and owner as specified; randomly generates the account number.

· public Account (String owner) - initializes the owner as specified; sets the initial balance to 0 and randomly generates the account number.

2. Overload the withdraw method with one that also takes a fee and deducts that fee from the account.

File TestAccount.java contains a simple program that exercises these methods. Save it to your directory, study it to see what it does, and use it to test your modified Account class.

//************************************************************

// Account.java

//

// A bank account class with methods to deposit to, withdraw from,

// change the name on, and get a String representation

// of the account.

//************************************************************

public class Account

{

private double balance;

private String name;

private long acctNum;

//-------------------------------------------------

//Constructor -- initializes balance, owner, and account number

//-------------------------------------------------

public Account(double initBal, String owner, long number)

{

balance = initBal;

name = owner;

acctNum = number;

}

//-------------------------------------------------

// Checks to see if balance is sufficient for withdrawal.

// If so, decrements balance by amount; if not, prints message.

//-------------------------------------------------

public void withdraw(double amount)

{

if (balance >= amount)

balance -= amount;

else

System.out.println("Insufficient funds");

}

//-------------------------------------------------

// Adds deposit amount to balance.

//-------------------------------------------------

public void deposit(double amount)

{

balance += amount;

}

//-------------------------------------------------

// Returns balance.

//-------------------------------------------------

public double getBalance()

{

return balance;

}

//-------------------------------------------------

// Returns a string containing the name, account number, and balance.

//-------------------------------------------------

public String toString()

{

return "Name:" + name +

"\nAccount Number: " + acctNum +

"\nBalance: " + balance;

}

}

//************************************************************

// TestAccount.java

//

// A simple driver to test the overloaded methods of

// the Account class.

//************************************************************

import java.util.Scanner;

public class TestAccount

{

public static void main(String[] args)

{

String name;

double balance;

long acctNum;

Account acct;

Scanner scan = new Scanner(System.in);

System.out.println("Enter account holder's first name");

name = scan.next();

acct = new Account(name);

System.out.println("Account for " + name + ":");

System.out.println(acct);

System.out.println("\nEnter initial balance");

balance = scan.nextDouble();

acct = new Account(balance,name);

System.out.println("Account for " + name + ":");

System.out.println(acct);

System.out.println("\nEnter account number");

acctNum = scan.nextLong();

acct = new Account(balance,name,acctNum);

System.out.println("Account for " + name + ":");

System.out.println(acct);

System.out.print("\nDepositing 100 into account, balance is now ");

acct.deposit(100);

System.out.println(acct.getBalance());

System.out.print("\nWithdrawing $25, balance is now ");

acct.withdraw(25);

System.out.println(acct.getBalance());

System.out.print("\nWithdrawing $25 with $2 fee, balance is now ");

acct.withdraw(25,2);

System.out.println(acct.getBalance());

System.out.println("\nBye!");

}

}

IV. Opening and Closing Accounts

File Account.java (see previous exercise) contains a definition for a simple bank account class with methods to withdraw, deposit, get the balance and account number, and return a String representation. Note that the constructor for this class creates a random account number. Save this class to your directory and study it to see how it works. Then write the following additional code:

1. Suppose the bank wants to keep track of how many accounts exist.

a. Declare a private static integer variable numAccounts to hold this value. Like all instance and static variables, it will be initialized (to 0, since it’s an int) automatically.

b. Add code to the constructor to increment this variable every time an account is created.

c. Add a static method getNumAccounts that returns the total number of accounts. Think about why this method should be static - its information is not related to any particular account.

d. File TestAccounts1.java contains a simple program that creates the specified number of bank accounts then uses the getNumAccounts method to find how many accounts were created. Save it to your directory, then use it to test your modified Account class.

2. Add a method void close() to your Account class. This method should close the current account by appending “CLOSED” to the account name and setting the balance to 0. (The account number should remain unchanged.) Also decrement the total number of accounts.

3. Add a static method Account consolidate(Account acct1, Account acct2) to your Account class that creates a new account whose balance is the sum of the balances in acct1 and acct2 and closes acct1 and acct2. The new account should be returned. Two important rules of consolidation:

· Only accounts with the same name can be consolidated. The new account gets the name on the old accounts but a new account number.

· Two accounts with the same number cannot be consolidated. Otherwise this would be an easy way to double your money!

Check these conditions before creating the new account. If either condition fails, do not create the new account or close the old ones; print a useful message and return null.

4. Write a test program that prompts for and reads in three names and creates an account with an initial balance of $ 100 for each. Print the three accounts, then close the first account and try to consolidate the second and third into a new account.

Now print the accounts again, including the consolidated one if it was created.

//************************************************************

// TestAccounts1

// A simple program to test the numAccts method of the

// Account class.

//************************************************************

import java.util.Scanner;

public class TestAccounts1

{

public static void main(String[] args)

{

Account testAcct;

Scanner scan = new Scanner(System.in);

System.out.println("How many accounts would you like to create?");

int num = scan.nextInt();

for (int i=1; i<=num; i++)

{

testAcct = new Account(100, "Name" + i);

System.out.println("\nCreated account " + testAcct);

System.out.println("Now there are " + Account.numAccounts () +

" accounts");

}

}

}

V. Transfering Funds

File Account.java (see A Flexible Account Class exercise) contains a definition for a simple bank account class with methods to withdraw, deposit, get the balance and account number, and print a summary. Save it to your directory and study it to see how it works. Then write the following additional code:

1. Add a method public void transfer(Account acct, double amount) to the Account class that allows the user to transfer funds from one bank account to another. If acct1 and acct2 are Account objects, then the call acct1.transfer(acct2,957.80) should transfer $957.80 from acct1 to acct2. Be sure to clearly document which way the transfer goes!

2. Write a class TransferTest with a main method that creates two bank account objects and enters a loop that does the following:

· Asks if the user would like to transfer from account1 to account2, transfer from account2 to account1, or quit.

· If a transfer is chosen, asks the amount of the transfer, carries out the operation, and prints the new balance for each account.

· Repeats until the user asks to quit, then prints a summary for each account.

3. Add a static method to the Account class that lets the user transfer money between two accounts without going through either account. You can (and should) call the method transfer just like the other one - you are overloading this method.

Your new method should take two Account objects and an amount and transfer the amount from the first account to the second account. The signature will look like this:

public static void transfer(Account acct1, Account acct2, double amount)

Modify your TransferTest class to use the static transfer instead of the instance version.

Deliverables

1. Complete all the activities in this lab; then zip all your Java SOURCE CODE FILES for submission.

2. Write a lab report in Word or PDF document. The report should be named lab4.docx or lab4.pdf and must contain the following:

a. The first page should be a cover page that includes the Class Number, Lab Activity Number, Date, and Instructor’s name.

b. A description of the lab activities, the concepts learned and applied. Be sure to elaborate on all the concepts applied. A minimum of 2-page description is expected.

c. A 1-paragraph conclusion about your experience; how long you spent completing the lab, the challenges you faced.

3. Upload your lab report and the zip file of your source code to Blackboard. DO NOT SUBMIT separate source files. If you do, they will be ignored.

Homework is Completed By:

Writer Writer Name Amount Client Comments & Rating
Instant Homework Helper

ONLINE

Instant Homework Helper

$36

She helped me in last minute in a very reasonable price. She is a lifesaver, I got A+ grade in my homework, I will surely hire her again for my next assignments, Thumbs Up!

Order & Get This Solution Within 3 Hours in $25/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 3 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 6 Hours in $20/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 6 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 12 Hours in $15/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 12 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

6 writers have sent their proposals to do this homework:

24/7 Assignment Help
Top Class Engineers
Quick Mentor
Engineering Guru
Isabella K.
Write My Coursework
Writer Writer Name Offer Chat
24/7 Assignment Help

ONLINE

24/7 Assignment Help

I am an academic and research writer with having an MBA degree in business and finance. I have written many business reports on several topics and am well aware of all academic referencing styles.

$21 Chat With Writer
Top Class Engineers

ONLINE

Top Class Engineers

As per my knowledge I can assist you in writing a perfect Planning, Marketing Research, Business Pitches, Business Proposals, Business Feasibility Reports and Content within your given deadline and budget.

$43 Chat With Writer
Quick Mentor

ONLINE

Quick Mentor

I have read your project details and I can provide you QUALITY WORK within your given timeline and budget.

$20 Chat With Writer
Engineering Guru

ONLINE

Engineering Guru

I have worked on wide variety of research papers including; Analytical research paper, Argumentative research paper, Interpretative research, experimental research etc.

$30 Chat With Writer
Isabella K.

ONLINE

Isabella K.

Being a Ph.D. in the Business field, I have been doing academic writing for the past 7 years and have a good command over writing research papers, essay, dissertations and all kinds of academic writing and proofreading.

$48 Chat With Writer
Write My Coursework

ONLINE

Write My Coursework

I have assisted scholars, business persons, startups, entrepreneurs, marketers, managers etc in their, pitches, presentations, market research, business plans etc.

$26 Chat With Writer

Let our expert academic writers to help you in achieving a+ grades in your homework, assignment, quiz or exam.

Similar Homework Questions

Classification Exercise - How to evaluate square roots without a calculator - Health history interview techniques - Identify the subordinate clause - Motec m400 wiring diagram - They say i say difference between second and third edition - 490 RN Reflection Assignment week 2 and 3 - Dermnet skin disease atlas - Information technology interview questions answers - Assessment Type: Individual Assignment and Video presentation Weighting: 20 % Total Marks: 20 - What ice cream flavor am i - Moore machine in automata - Introduction to leadership peter g northouse pdf - What is the difference between intervention research and systems research - Discussion: Growth, Inequality and Poverty - Ds 7732ni i4 16p firmware - Ge iron grip near me - Recrystallization theoretical yield - According to the attraction selection attrition theory job applicants - When and where the story takes place - Should the electoral college be abolished pros and cons - Does history repeat itself evidence from the course - Xtm helios 224 review - Security Policy Plan - Fuel injector driver circuit schematic - Vark analysis paper - +91-8890675453 love marriage problem solution IN Purnia - Dan gartrell theory and methods - Edwin lemert described primary deviance as - Example of stimulus generalization in marketing - Like the modernists postmodern writers focused on - Yorkshire pudding motorcycle rally - LEADERSHIP - Exercise 3.1 - Philippine normal university uniform - Topic 2 DQ 1 Patophysiology - Wayne rooney goal machine documentary - Florida drivers license lookup - Spark notes animal farm - That funny feeling bo burnham lyrics meaning - Leasehold property depreciation rate - Twin oaks health center has a bond issue outstanding - Hamad medical corporation residency - Scs 100 theme 1 comparison template - Candis magazine airport parking - Svoa sentence pattern examples - Phasor to rectangular calculator - 6.22 miles in km - As i grew older analysis - Is designed passive voice - Koch ag and energy solutions wichita ks - Why is it important that specific tissues respond to insulin - 76 animated looming phantom costco - Devil in the white city discussion questions answers - What is a quadrilateral with no parallel sides - Measurable iep organizational goals - Meet personal support needs - Costco meat plant tracy - Everyone's an author second - An important tool for project scope management is - R&b metal structures griffin ga - Which of the following statements is untrue regarding cold canvassing - Coca cola strengths and weaknesses - Recommended cutting speed for aluminum - Scratch beginnings chapter 13 summary - Biblical allusions in literature - Dragonfly red software update - On course 3rd edition pdf - Physical properties of paper - How to calculate ripple factor of half wave rectifier - Making the right choices - How to bend tattoo springs - In supplying private label footwear to chain retailers - Does rap stand for rhythm and poetry - Which of the following is a source of cash - Robert potamkin net worth - Osi international foods brisbane - Conflict resolution strategies in healthcare - Is no2- polar or nonpolar - These wounds won t seem to heal lyrics - Discussion 09.1: Correlation and Regression - Uniqlo mission and vision - Convert docs to sheets - 20.4 run ons practice 2 answers - Module 8 Discussion Forum: Social Media Discussion Post - Interdependence - Hand drill press attachment - My favourite toy car 5 lines - What is intentional rounding - Osborne in journey's end - Public and private families 8th edition pdf - Tales of yoruba gods and heroes - Freud erikson piaget kohlberg chart - Estimate then record the product lesson 2.7 - Confidence Intervals and Sample Size - Pain among older adult - Course Paper 2: Public Management of Undocumented Immigrants - 11.2 comparing data displayed in box plots answer key - Air quality webquest key - Article Research Paper 2