Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java INSTRUCTION YOU NEED TO MODIFY BANK ACCOUNT UNDER ACCEPT Y WHERE IT WILL ONLY ACCEPT BANK ACCOUNTS OF VALUES OF 1000 OR MORE AND

java

INSTRUCTION YOU NEED TO MODIFY BANK ACCOUNT UNDER ACCEPT Y WHERE IT WILL ONLY ACCEPT BANK ACCOUNTS OF VALUES OF 1000 OR MORE AND UNDER THE DATA FILE YOU WILL NEED TO FIND THE SUM OF THE BANK ACCOUNTS THAT IS 1000 OR MORE FOR AN EXAMPLE MY TEST FILE IT HAS ACCOUNT 1 = 0 AND ACCOUNT 2 = 10000 AND ACCOUNT 3 = 2000 SO IT WILL GET ACCOUNT 2 AND ACCOUNT 3 DIVIDE THE NUMBER OF ACCOUNTS SO 2 ---> (10000+2000)/2=6000 SHOULD BE OUPUT ONLY NEED TO MODIFY ^^^^ DOES FILES

Measurbale

/** Describes any class whose objects can be measured. */ public interface Measurable { /** Computes the measure of the object. @return the measure */ double getMeasure(); }

BankAccount

/** A bank account has a balance that can be changed by deposits and withdrawals. */ public class BankAccount implements Measurable, Filter { private double balance;

/** Constructs a bank account with a zero balance. */ public BankAccount() { balance = 0; }

/** Constructs a bank account with a given balance. @param initialBalance the initial balance */ public BankAccount(double initialBalance) { balance = initialBalance; }

/** Deposits money into the bank account. @param amount the amount to deposit */ public void deposit(double amount) { balance = balance + amount; }

/** Withdraws money from the bank account. @param amount the amount to withdraw */ public void withdraw(double amount) { balance = balance - amount; }

/** Gets the current balance of the bank account. @return the current balance */ public double getBalance() { return balance; }

public double getMeasure() { return balance; } public boolean Accept(Object Y) { return true; } }

Filter

/** * Write a description of interface Filter here. * * @author (your name) * @version (a version number or a date) */ public interface Filter { boolean Accept(Object X); }

Country

/** A country with a name and area. */ public class Country implements Measurable { private String name; private double area;

/** Constructs a country. @param aName the name of the country @param anArea the area of the country */ public Country(String aName, double anArea) { name = aName; area = anArea; }

/** Gets the country name. @return the name */ public String getName() { return name; }

/** Gets the area of the country. @return the area */ public double getArea() { return area; }

public double getMeasure() { return area; } }

Data

public class Data { /** Computes the average of the measures of the given objects. @param objects an array of Measurable objects @return the average of the measures */ public static double average(Measurable[] objects) { double sum = 0; for (Measurable obj : objects) { sum = sum + obj.getMeasure(); } if (objects.length > 0) { return sum / objects.length; } else { return 0; } } }

MeasurableTester

/** This program demonstrates the measurable BankAccount and Country classes. */ public class MeasurableTester { public static void main(String[] args) { Measurable[] accounts = new Measurable[3]; accounts[0] = new BankAccount(0); accounts[1] = new BankAccount(10000); accounts[2] = new BankAccount(2000);

double averageBalance = Data.average(accounts); System.out.println("Average balance: " + averageBalance); System.out.println("Expected: 4000");

Measurable[] countries = new Measurable[3]; countries[0] = new Country("Uruguay", 176220); countries[1] = new Country("Thailand", 513120); countries[2] = new Country("Belgium", 30510);

double averageArea = Data.average(countries); System.out.println("Average area: " + averageArea); System.out.println("Expected: 239950"); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions

Question

State the uses of job description.

Answered: 1 week ago

Question

Explain in detail the different methods of performance appraisal .

Answered: 1 week ago

Question

18. If you have power, then people will dislike and fear you.

Answered: 1 week ago