1. In the CheckingAccount class: a. Create one method for depositing. The deposit method should have one parameter to indicate the amount to be deposited. You must make sure the amount to be deposited is positive. b. Create one method for withdrawing. The withdraw method should have one parameter to indicate the amount to be withdrawn and use Boolean return type to show the success of the operation. If the amount to be withdrawn is negative or one tries to over-withdraw (i.e the withdrawing amount is more than the balance), make no change on the balance and return false. If the withdrawn amount is allowed, update the balance by subtracting this withdrawing amount from it and then return true. c. Create a displayAccount() method.i. Print a nice head that includes the customer’s name (similar to the Employee class example)ii. Display the account number, owner’s name, and current balance, each at a separate line 2. Modify the main method in the CheckingAccountDemo class a. Take out all codes from Lab 7. b. Ask for the name, account number, and initial balance for one account from the keyboard input. Create a CheckingAccount object and initialize it using the constructor and the keyboard input values on name, account number, and initial balance. Call the displayAccount() method to print the summary of this account. c. Ask user to input the deposit amount from keyboard, then deposit it into the account you created by calling the deposit method of the CheckingAccount object you have created. Call the displayAccount() method to print the summary of this account. d. Ask user to input the withdraw amount from keyboard, then try to withdraw that amount from the account object. If the operation is successful, call the displayAccount() method to print the summary of this account. Otherwise print the error information that the withdrawing operation failed.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

This code is used for the question being asked at the bottom.

 

public class AccountBalance {
private long accountNumber;
private String ownersName;
private double balance;

public AccountBalance(long accountNumber, String ownersName, double balance) {
this.accountNumber = accountNumber;
this.ownersName = ownersName;
setBalance(balance);
}
public long getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(long accountNumber) {
this.accountNumber = accountNumber;
}
public String getOwnersName() {
return ownersName;
}
public void setOwnersName() {
this.ownersName = ownersName;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
if (balance < 0) {
System.out.println("Balance Cannot be Negative.");
balance = 0;
}
this.balance = balance;
}
}

import java.util.Scanner;
public class AccountBalanceDemo {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

System.out.print("Enter the name of the account holder: ");
String name = sc.nextLine();

System.out.print("Enter the Account Number: ");
long an = sc.nextLong();

System.out.println("Enter the account balance: ");
double balance = sc.nextDouble();

AccountBalance ab = new AccountBalance(an, name, balance);

System.out.println("Name: " + ab.getOwnersName());
System.out.println("Account Number: " + ab.getAccountNumber());
System.out.println("Balance: " + ab.getBalance());
}

}

 

Continue your work on Lab7.

1. In the CheckingAccount class:

a. Create one method for depositing. The deposit method should have one parameter to indicate the amount to be deposited. You must make sure the amount to be deposited is positive.

b. Create one method for withdrawing. The withdraw method should have one parameter to indicate the amount to be withdrawn and use Boolean return type to show the success of the operation. If the amount to be withdrawn is negative or one tries to over-withdraw (i.e the withdrawing amount is more than the balance), make no change on the balance and return false. If the withdrawn amount is allowed, update the balance by subtracting this withdrawing amount from it and then return true.

c. Create a displayAccount() method.i. Print a nice head that includes the customer’s name (similar to the Employee class example)ii. Display the account number, owner’s name, and current balance, each at a separate line

2. Modify the main method in the CheckingAccountDemo class

a. Take out all codes from Lab 7.

b. Ask for the name, account number, and initial balance for one account from the keyboard input. Create a CheckingAccount object and initialize it using the constructor and the keyboard input values on name, account number, and initial balance. Call the displayAccount() method to print the summary of this account.

c. Ask user to input the deposit amount from keyboard, then deposit it into the account you created by calling the deposit method of the CheckingAccount object you have created. Call the displayAccount() method to print the summary of this account.

d. Ask user to input the withdraw amount from keyboard, then try to withdraw that amount from the account object. If the operation is successful, call the displayAccount() method to print the summary of this account. Otherwise print the error information that the withdrawing operation failed.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY