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

output should be

Average balance: 2000.0 Expected: 2000 Average area: 239950.0 Expected: 239950

2000 + 2000/2 = 2000

if you dont have that don't post the answer show output for a upvote

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(2000); 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_2

Step: 3

blur-text-image_step3

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

ISBN: 1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

LO3 Define job design and identify common approaches to job design.

Answered: 1 week ago