The BankAccount class described below is used to represent a personal savings account with a yearly interest rate, (represented as a percentage, e.g., a 7% rate is represented by .07). The interest is applied monthly, (i.e., at the end of each month 1/12 of the interest is deposited into the account).
public class BankAccount
{ public BankAccount(double rate)
public BankAccount(double initBal, double rate)
public double getBalance()
public double getIntRate()
public void setIntRate(double rate)
public void deposit(double amount)
public void withdraw(double amount)
public void addMonthsInterest()
private double balance;
private double intRate;
}
Suppose a bank offers to its special customers a new type of savings account, called a “Credit Account”, that allows the customer to withdraw extra money if needed, so that the account balance is allowed to be negative at some times. These accounts award interest at the end of every month, as long as the balance is positive. If the balance is negative, then the account is charged the monthly interest for the negative amount, plus 0.5%.
In addition, any withdrawals to an account with a non-positive balance are charged a fee of $2. Provide the code for this extension class. Be sure to include constructor methods and override the appropriate methods.
Step by stepSolved in 3 steps with 3 images
- java program 1. Write a Park class with the following class variables: 1) String ParkName; 2) int ParkID; 3) String ParkShape; and 4) double ParkLength. Please implement the following methods: i) ParkNameGetter(): Return the name of the park. ii) ParkIDGetter(): Return the ID of the park. iii) ParkLengthGetter(): Return the length of the park. Note that, 1) ParkLength is private while the other variables are public. 2) ParkShape only includes “Circle” and “Square”. 3) Parks may have the same name, but ParkID is unique. 4) Students should create the correct constructor. 2. Write a ParkClient class. i) Create an array of Park: - ParkArray has 5 elements; - Set the first park in ParkArray with the following parameters: ParkName: BIRCH, ParkID: 20, ParkShape: “Circle”, ParkLength: 5. - Set the second park in ParkArray with the following parameters: ParkName: BIRCH, ParkID: 23, ParkShape: “Square”, ParkLength: 6. - Randomly Set the other three parks in ParkArray. ii) Print out the…arrow_forwardI have the following code: public class Length{ private int feet; private int inches; Length() { feet = inches = 0; } Length(int newFeet, int newInches) { feet = newFeet; inches = newInches; } public int getFeet() { return feet; } public void setFeet(int newFeet) { feet = newFeet; } public int getInches() { return inches; } public void setInches(int newInches) { inches = newInches; } public void add(Length otherLength) { int newFeet = this.feet + otherLength.feet; int newInches = this.inches + otherLength.inches; if(newInches >= 12) { newFeet++; newInches -= 12; } this.setFeet(newFeet); this.setInches(newInches); } public Length subtract(Length otherLength) { if(this.feet > otherLength.feet) { int newFeet = feet - otherLength.feet; int newInches = inches - otherLength.inches;…arrow_forwardAssume you have the following two classes: public class Bag{ private String name; public Bag() { name = "Fancy bag"; } } public class Backpack extends Bag { private int noCompartments; // number of compartments in a backpack public Backpack() { noCompartments = 1; } %3D public int getNoCompartments() { return noCompartments; } } Assume that you have a variable of type Bag initialized to an object instance of type Backpack, as follows: Bag bag = new Backpack(); Show a fragment of code to print the number of compartments in a Bag referenced by the variable bag, as assigned above.arrow_forward
- Time This class is going to represent a 24-hour cycle clock time. That means 0:0:0 (Hour:Minute:Second) is the beginning of a day and 23:59:59 is the end of the day. This class has these data members. int sec int min int hourarrow_forwardThe Temperature class is an abstract class with two abstract methods. Create the Conversion class which inherits from Temperature. Use the formulas below to help with the temperature conversions. CODE: abstract class Temperature { public abstract double celsius(double temp); public abstract double fahrenheit(double temp);} //add class definitions below this line //add class definitions above this line public class Exercise3 { public static void main(String[] args) { //add code below this line Conversion c = new Conversion(); //add code above this line }}arrow_forwardPython Code please Point of Sale Write a program that will manage the point of sale in a store. Build the ItemToPurchase class with the following: Attributes item_name (string) item_price (int) item_quantity (int) Default constructor Initializes item's name = "none", item's price = 0, item's quantity = 0 Method print_item_cost() Example of print_item_cost() output:Bottled Water 10 @ $1 = $10 Extend the ItemToPurchase class to contain a new attribute. item_description (string) - Set to "none" in default constructor Implement the following method for the ItemToPurchase class. print_item_description() - Prints item_description attribute for an ItemToPurchase object. Has an ItemToPurchase parameter. Example of print_item_description() output:Bottled Water: Deer Park, 12 oz. Build the ShoppingCart class with the following data attributes and related methods. Note: Some can be method stubs (empty methods) initially, to be completed in later steps. Parameterized constructor…arrow_forward
- In a population, the birth rate and death rate are calculated as follows:Birth Rate = Number of Births ÷ Population Death Rate = Number of Deaths ÷ PopulationFor example, in a population of 100,000 that has 8,000 births and 6,000 deaths 2per year,Birth Rate = 8,000 ÷ 100,000 = 0.08 Death Rate = 6,000 ÷ 100,000 = 0.06Design a Population class that stores a current population, annual number of births, and annual number of deaths for some geographic area. The class should allow these three values to be set in either of two ways: by passing arguments to a three-parameter constructor when a new Population object is created or by calling the set_population, set_births, and set_deaths class member functions. The class should also have get_birth_rate and get_death_rate functions that compute and return the birth and death rates. Write a short program that uses the Population class and illustrates its capabilities.Input Validation: If a population figure less than 2 is passed to the class, use…arrow_forwardCode the StudentAccount class according to the class diagramMethods explanation:pay(double): doubleThis method is called when a student pays an amount towards outstanding fees. The balance isreduced by the amount received. The updated balance is returned by the method.addFees(double): doubleThis method is called to increase the balance by the amount received as a parameter. The updatedbalance is returned by the method.refund(): voidThis method is called when any monies owned to the student is paid out. This method can onlyrefund a student if the balance is negative. It displays the amount to be refunded and set thebalance to zero. (Use Math.abs(double) in your output message). If there is no refund, display anappropriate message.Test your StudentAccount class by creating objects and calling the methods addFees(), pay() andrefund(). Use toString() to display the object’s data after each method calledarrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY