I am doing a lab and I get this error message in my unittest: junit.framework.AssertionFailedError: Hint: matches() should have returned true when item matches the item passed into IdLookup constructor. Here is my code. What changes should be made?
/**
* This class is a lookup that matches items whose id matches
exactly
* a specified id, to be passed into the constructor when
creating
* the instance of the lookup.
*
* @author Franklin University
* @version 2.0
*/
public class IdLookup implements Lookup
{
private String lookupId;
/**
* Constructor for objects of class IdLookup.
* @param id the id to lookup.
*/
public IdLookup(String id)
{
lookupId = id;
}
/**
* Indicates whether the item's id exactly matches the id
* passed into the contructor.
* @param item the item being checked for a match.
* @return true if the id of the item matches, otherwise
* false.
*/
@Override
public boolean matches(Item item)
{
if (item == null) {
return false;
}
return lookupId == item.getId();
}
}
In: Computer Science
Read the article below and as you’re reading it translate how the ‘utility’ concepts in this week’s lesson are applied in the article. Note, for example, that the author talks about ‘value’ relative to price. This indicates to you that ‘utility’ is sometimes referred to as ‘value’ by some marketers.
Hall, Doug. (Dec 13, 2007). Jump Start: Perceiving is Believing. Bloomberg Business Week.
Preview the document
Now, look for a news headline that illustrates basic utility concepts (such as MU, TU, MU/P, etc.). Quote (post) the headline and cite properly (so that others like classmates and instructors can find your headline easily, using your citation), and explain precisely what utility concepts are illustrated and how they are applied in the story suggested by the headline. OR: Upload a photo of something you observed or noticed in a marketplace that illustrates utility and consumer choice. and explain precisely what utility concepts are illustrated and how they are applied in the shot that you’ve uploaded.
In: Economics
Stanford University medical researchers conducted a study on the correlation between the use of fertility drugs and ovarian cancer. Their study, published in the American Journal of Epidemiology, concludes that the use of the fertility drugs, Pergonal and Serophene, may increase the risk of ovarian cancer by three times. The lead author of the studies, Professor Alice Whittemore, stated, "Our finding in regard to fertility drugs is by no means certain. It is based on very small numbers and is really very tenuous."
FDA Commissioner David Kessler would like the infertility drug manufacturers to disclose the study findings and offer a warning on the drug packages. He notes, "Even though the epidemiology study is still preliminary, women have a right to know what is known. We're not looking to make more of this than there is."
If you were a manufacturer of one of the drugs, would you voluntarily disclose the study information?
Please Answer the above Questions No Plagiarism NEED 400 WORDS
In: Operations Management
Deviance/Global Stratification
Choose a piece of popular fiction—novel, short story, graphic novel, or comic book—and research the material through the lens of popular culture and its effect on society.
Prepare a 500- to 750-word analysis that includes a critique of that work and a commentary on the influence of the work in popular culture. Address the following:
• Identify the literary production you chose to focus on. Provide a brief overview of what the piece is about, the author’s background, and how the piece fits or does not fit with other literature of that genre.
• What is the cultural significance of the work Reflect on whether the piece is considered economically successful or if it has fan followings.
• What cultural values are reinforced or challenged in the work?
Consider the following examples:
• How the Harry Potter novels are encouraging young adults to read
• Does the Twilight series reinforce or challenge traditional gender roles?
• The quest for truth in the novels of Dan Brown, author of The Da Vinci Code and Angels & Demons
In: Psychology
Section One:
Write a review of “Dirigible Dreams” that answers the following three questions:
1) What was the purpose of the book?
2) Did the author successfully complete the purpose of the book or did he accomplish less than the purpose? Thoroughly explain your positions and reference sections of the book that support your comments.
3) Did you find “Dirigible Dreams” useful in understanding the development of transportation (or not)? Be explicit, offer examples, and tell me what you liked and did not like about the book (and why).
Section Two:
Compare what you learned in “Dirigible Dreams” to the development of another form of transportation. First, identify specific points of comparison, then apply those points of comparison between the development of airships to your chosen “other” form of transportation.
You may choose a form of transportation that was successfully (or unsuccessfully) developed in the past, or a development(s) that is happening today. For example, compare “Dirigible Dreams” to the development of LNG-powered ships.
In: Operations Management
Throughout this chapter, you were encouraged to take control of your life and establish your own definition of success. This chapter has a strong “all development is self development” theme. Can we really control our own destinies? Can we always make our own choices? Mike Hernacki, author of The Ultimate secret of getting absolutely everything you want, says yes: to get what you want, you must recognize something that at first may be difficult, even painful to look at. You must recognize that you alone are the source of all the conditions and situations in your life. You must recognize that whatever your world looks like right now, you alone have caused it to look that way. The state of your health, your finances, your personal relationships, your professional life, all of it is you're doing, yours and no one else's.
In: Operations Management
Can you please tell me if this code needs to be fixed, if it does can you please post the fixed code below please and thank you
/**
* Driver to demonstrate WholeLifePolicy class.
*
* @author Tina Comston
* @version Fall 2019
*/
public class WholeLifePolicyDriver
{
/**
* Creates WholeLifePolicy object, calls methods, displays
values.
*
*/
public static void main()
{
WholeLifePolicyDriver myDriver = new WholeLifePolicyDriver();
// create a policy
WholeLifePolicy policy = new WholeLifePolicy("WLP1234567",
50000, 20);
// display values
myDriver.displayPolicy(policy);
// now change some values
policy.setPolicyNum("WLP9871235");
policy.setFaceValue(75000);
policy.setPolicyYrs(15);
// display again
myDriver.displayPolicy(policy);
// Display termination value at 10 years, borrowed $25K
System.out.printf("Termination value @10 years 25K borrowed "
+
"is %.2f \n", policy.surrenderVal(10.0, 25000));
}
/**
* Displays data for a policy.
*
*/
private void displayPolicy(WholeLifePolicy wlp)
{
System.out.println("*******************************************");
System.out.println(wlp.toString());
System.out.println();
}
}
In: Computer Science
C++ language
Using classes (OOD), design a system that will support lending various types of media starting with books. Program should be able to handle a maximum of 500 books. Program should meet at least the following requirements:
1. Define a base media class with a book class derived from it. (Specific class names determined by programmer.)
2. The classes should contain at least the following information: title, up to four authors, ISBN.
3. Define a collection class that will hold up to 500 books.
4. The program should be able to perform the following operations supported by the class definitions:
a) Load data from a drive
b)Sort and display the books by title
c)Sort and display the books by author
d)Add and remove books
Programming requirements: Must include examples of inheritance and composition
~~~Function/Class comments (Description, pre and post conditions)
~~~Internal comments for all functions
In: Computer Science
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile and Execute.
The project is below, I have supplied the code and I'm getting an error in SavingsAccount.h file.
17 5 C:\Users\adam.brunell\Documents\Classes\C++\Week4\SavingsAccount.h [Error] 'SavingsAccount::SavingsAccount(std::string, double, double)' is protected
A.Assume
i.SavingsAccount: Assume an Interest Rate of 0.03
ii.HighInterestSavings: Assume an Interest Rate of 0.05, Minimum Balance = $2500
iii.NoServiceChargeChecking: Assume an Interest Rate = 0.02, Minimum of Balance = $1000
iv.ServiceChargeChecking – Assume account service charge = $10, Maximum number of checks = 5, Service Charge if customer exceeds the maximum number of checks = $5.
v.NoServicechargeChecking: Assume an interest rate = 0.02, Minimum Balance = $1000
vi.HighInterestChecking: Assume an interest rate = 0.05, Minimum Balance = $5000
vii.CertificateOfDepsit: Assume an interest rate = 0.05, Initial Number of Maturity Months = 6
B.Capitalize the first letter of the derived class names.
C.Use the following driver to validate your program:
#include
#include
#include
#include "bankAccount.h"
#include "SavingsAccount.h"
#include "HighInterestSavings.h"
#include "NoServiceChargeChecking.h"
#include "ServiceChargeChecking.h"
#include "HighInterestChecking.h"
#include "CertificateOfDeposit.h"
#include "checkingAccount.h"
using namespace std;
int main()
{
vector accountsList;
//SavingsAccount( Name, Account number, Balance ) - Assume an interest rate = 0.03
accountsList.push_back(new SavingsAccount("Bill", 10200, 2500));
//HighInterestSavings(Name, Account Number, Balance) -- Assume an interest rate = 0.05, Minimum balance = $2500
accountsList.push_back(new HighInterestSavings("Susan", 10210, 2000));
//NoServiceChargeChecking(Name, Account Number, Balance) -- Assume an interest rate = 0.02, Minimum balance = $1000
accountsList.push_back(new NoServiceChargeChecking("John", 20100,
3500));
//ServiceChargeChecking(Name, Account Number, Balance) -- Assume account service charge = $10, Maximum number of checks = 5, Service Charee Excess Number of Checks = $5
accountsList.push_back(new ServiceChargeChecking("Ravi", 30100, 1800));
//HighIntererestChecking(Name, Account Number, Balance) - Assume an inerest rate = 0.05, Minimum balance = $5000
accountsList.push_back(new HighInterestChecking("Sheila", 20200, 6000));
//Certificate(name, Account Number, Balance, Interest Rate, Number of Months) - Assume an initial interest rate = 0.05, Initial Number of Maturity Months = 6
accountsList.push_back(new CertificateOfDeposit("Hamid", 51001, 18000,
0.075, 18));
cout << "January:\n-------------" << endl;
for (int i = 0; i < accountsList.size(); i++)
{
accountsList[i]->createMonthlyStatement();
accountsList[i]->print();
cout << endl;
}
cout << "\nFebruary:\n-------------" << endl;
for (int i = 0; i < accountsList.size(); i++)
{
accountsList[i]->createMonthlyStatement();
accountsList[i]->print();
cout << endl;
}
for (int i = 0; i < accountsList.size(); i++)
{
accountsList[i]->withdraw(500);
}
cout << "\nMarch:\n-------------" << endl;
for (int i = 0; i < accountsList.size(); i++)
{
accountsList[i]->createMonthlyStatement();
accountsList[i]->print();
cout << endl;
}
System(“pause”);
return 0;
}
The Expected Output is:
January:
-------------
Savings account: Bill ACCT# 10200 Balance: $2575.00
High Interest Savings: Susan ACCT# 10210 Balance: $2100.00
No Service Charge Check. John ACCT# 20100 Balance: $3500.00
Service Charge Checking: Ravi ACCT# 30100 Balance: $1790.00
Higher Interest Checking: Sheila ACCT# 20200 Balance: $6300.00
Certificate of Deposit: Hamid ACCT# 51001 Balance: $19350.00
February:
-------------
Savings account: Bill ACCT# 10200 Balance: $2652.25
High Interest Savings: Susan ACCT# 10210 Balance: $2205.00
No Service Charge Check. John ACCT# 20100 Balance: $3500.00
Service Charge Checking: Ravi ACCT# 30100 Balance: $1780.00
Higher Interest Checking: Sheila ACCT# 20200 Balance: $6615.00
Certificate of Deposit: Hamid ACCT# 51001 Balance: $20801.25
March:
-------------
Savings account: Bill ACCT# 10200 Balance: $2216.82
High Interest Savings: Susan ACCT# 10210 Balance: $2315.25
No Service Charge Check. John ACCT# 20100 Balance: $3000.00
Service Charge Checking: Ravi ACCT# 30100 Balance: $1270.00
Higher Interest Checking: Sheila ACCT# 20200 Balance: $6420.75
Certificate of Deposit: Hamid ACCT# 51001 Balance: $22361.34
Press any key to continue . . .
//testdriver.cpp
#include
#include
#include
#include "bankAccount.h"
#include "SavingsAccount.h"
#include "HighInterestSavings.h"
#include "NoServiceChargeChecking.h"
#include "ServiceChargeChecking.h"
#include "HighInterestChecking.h"
#include "CertificateOfDeposit.h"
#include "checkingAccount.h"
using namespace std;
int main()
{
vector accountsList;
//SavingsAccount( Name, Account number, Balance ) -
Assume an interest rate = 0.03
accountsList.push_back(new SavingsAccount("Bill", 10200,
2500));
//HighInterestSavings(Name, Account Number,
Balance) -- Assume an interest rate = 0.05, Minimum balance =
$2500
accountsList.push_back(new HighInterestSavings("Susan", 10210,
2000));
//NoServiceChargeChecking(Name, Account Number,
Balance) -- Assume an interest rate = 0.02, Minimum balance =
$1000
accountsList.push_back(new NoServiceChargeChecking("John",
20100,
3500));
//ServiceChargeChecking(Name, Account Number,
Balance) -- Assume account service charge = $10, Maximum number of
checks = 5, Service Charee Excess Number of Checks = $5
accountsList.push_back(new ServiceChargeChecking("Ravi", 30100,
1800));
//HighIntererestChecking(Name, Account Number,
Balance) - Assume an inerest rate = 0.05, Minimum balance =
$5000
accountsList.push_back(new HighInterestChecking("Sheila", 20200,
6000));
//Certificate(name, Account Number, Balance,
Interest Rate, Number of Months) - Assume an initial interest rate
= 0.05, Initial Number of Maturity Months = 6
accountsList.push_back(new CertificateOfDeposit("Hamid", 51001,
18000,
0.075, 18));
cout << "January:\n-------------" << endl;
for (int i = 0; i < accountsList.size(); i++)
{
accountsList[i]->createMonthlyStatement();
accountsList[i]->print();
cout << endl;
}
cout << "\nFebruary:\n-------------" << endl;
for (int i = 0; i < accountsList.size(); i++)
{
accountsList[i]->createMonthlyStatement();
accountsList[i]->print();
cout << endl;
}
for (int i = 0; i < accountsList.size(); i++)
{
accountsList[i]->withdraw(500);
}
cout << "\nMarch:\n-------------" << endl;
for (int i = 0; i < accountsList.size(); i++)
{
accountsList[i]->createMonthlyStatement();
accountsList[i]->print();
cout << endl;
}
System("pause");
return 0;
}
bankAccount.h
#ifndef BANKACCOUNT_H
#define BANKACCOUNT_H
#include
using namespace std;
class bankAccount {
public:
bankAccount(string name, double initialBalance);
string getName();
unsigned int getAccountNumber();
double getBalance();
double getInterestRate();
string getStatementString();
void deposit(double amount);
void deposit(double amount, string statement);
void withdraw(double amount);
void withdraw(double amount, string statement);
virtual void printStatement() = 0;
protected:
void addStatementLine(string statement, double amount);
private:
string name;
unsigned int accountNumber;
double balance;
static unsigned int nextAccountNumber;
string statementString;
};
#endif /* BANKACCOUNT_H */
//bankAccount.cpp
#include "bankAccount.h"
#include
#include
#include
using namespace std;
unsigned int BankAccount::nextAccountNumber = 1;
BankAccount::BankAccount(string name, double initialBalance)
{
stringstream output;
this->name = name;
balance = initialBalance;
accountNumber = nextAccountNumber++;
output << setw(60) << left << "Transaction"
<< setw(10) << "Amount" << " " << "Balance"
<< endl;
statementString = output.str();
addStatementLine("Initial Deposit", initialBalance);
}
string BankAccount::getName()
{
return name;
}
unsigned int BankAccount::getAccountNumber()
{
return accountNumber;
}
double BankAccount::getBalance()
{
return balance;
}
void BankAccount::addStatementLine(string statement, double
amount)
{
stringstream output;
output << setw(60) << left << statement <<
setw(10) << amount << " " << getBalance()
<< endl;
//.append(statement);
statementString.append(output.str());
}
void BankAccount::deposit(double amount)
{
deposit(amount, "Deposit");
}
void BankAccount::deposit(double amount, string statement)
{
balance += amount;
addStatementLine(statement, amount);
}
void BankAccount::withdraw(double amount)
{
withdraw(amount, "Withdrawal");
}
void BankAccount::withdraw(double amount, string
statement)
{
if (balance >= amount)
{
balance -= amount;
addStatementLine(statement, amount);
}
else
{
addStatementLine(statement.append(" Overdraft"), amount);
}
}
string BankAccount::getStatementString()
{
return statementString;
}
//CertificateOfDeposit.h
#ifndef CERTIFICATEOFDEPOSIT_H
#define CERTIFICATEOFDEPOSIT_H
#include "bankAccount.h"
#include
using namespace std;
class CertificateOfDeposit : public bankAccount{
public:
CertificateOfDeposit(string name, double initialBalance, int
maturityMonths);
CertificateOfDeposit(string name, double initialBalance);
int getMaturityMonths();
double getInterestRate();
int getCurrentCDMonth();
int getWithdrawalPenaltyMonths();
void withdraw();
void incrementMonth();
void printStatement();
private:
int maturityMonths;
double interestRate;
int currentCDMonth;
int withdrawalPenaltyMonths;
void withdraw(double amount);
void withdraw(double amount, string statement);
void deposit(double amount);
};
#endif /* CERTIFICATEOFDEPOSIT_H */
//CertificateOfDeposit.cpp
#include "CertificateOfDeposit.h"
CertificateOfDeposit::CertificateOfDeposit(string name, double
initialBalance, int maturityMonths) : bankAccount(name,
initialBalance)
{
this->maturityMonths = maturityMonths;
interestRate = 0.05;
currentCDMonth = 0;
withdrawalPenaltyMonths = 3;
}
CertificateOfDeposit::CertificateOfDeposit(string name, double
initialBalance) : bankAccount(name, initialBalance)
{
maturityMonths = 6;
interestRate = 0.05;
currentCDMonth = 0;
withdrawalPenaltyMonths = 3;
}
int CertificateOfDeposit::getCurrentCDMonth()
{
return currentCDMonth;
}
double CertificateOfDeposit::getInterestRate()
{
return interestRate;
}
int CertificateOfDeposit::getWithdrawalPenaltyMonths()
{
return withdrawalPenaltyMonths;
}
int CertificateOfDeposit::getMaturityMonths()
{
return maturityMonths;
}
void CertificateOfDeposit::withdraw()
{
if (getCurrentCDMonth() < getMaturityMonths())
bankAccount::withdraw(getBalance()*getInterestRate()*getWithdrawalPenaltyMonths(),
"Early Withdrawal Penalty");
bankAccount::withdraw(getBalance(), "Close Account");
}
void CertificateOfDeposit::incrementMonth()
{
bankAccount::deposit(getBalance()*getInterestRate(), "Monthly
Interest");
if (getCurrentCDMonth() < getMaturityMonths())
{
currentCDMonth++;
}
else
withdraw();
}
void CertificateOfDeposit::printStatement()
{
cout << "Certificate of Deposit Statement" <<
endl;
cout << "Name: " << getName() << endl;
cout << "Account Number: " << getAccountNumber()
<< endl;
cout << "Interest Rate: " << getInterestRate() * 100
<< "%" << endl;
cout << "Maturity Month: " << getMaturityMonths()
<< ", Current Month: " << getCurrentCDMonth() <<
endl;
cout << "Early Withdrawal Penalty: " <<
getWithdrawalPenaltyMonths() << " (months)" << endl
<< endl;
cout << getStatementString() << endl;
cout << "Final Balance: " << getBalance() << endl
<< endl;
}
//HighInterestChecking.h
#ifndef HIGHINTERESTCHECKING_H
#define HIGHINTERESTCHECKING_H
#include "NoServiceChargeChecking.h"
#include
using namespace std;
class HighInterestChecking : public NoServiceChargeChecking
{
public:
HighInterestChecking(string name, double initialBalance);
void printStatement();
private:
};
#endif /* HIGHINTERESTCHECKING_H */
//HighInterestChecking.cpp
#include "HighInterestChecking.h"
HighInterestChecking::HighInterestChecking(string name, double
initialBalance) : NoServiceChargeChecking(name, initialBalance,
5000, 0.05)
{
}
void HighInterestChecking::printStatement()
{
bankAccount::deposit(getBalance() * getInterestRate(),
"Interest");
cout << "High Interest Checking Statement" <<
endl;
cout << "Name: " << getName() << endl;
cout << "Account Number: " << getAccountNumber()
<< endl;
cout << "Interest Rate: " << getInterestRate() * 100
<< "%" << endl;
cout << "Minimum Balance: " << getMinimumBalance()
<< endl << endl;
cout << getStatementString() << endl;
cout << "Final Balance: " << getBalance() << endl
<< endl;
}
//HighInterestSavings.h
#ifndef HIGHINTERESTSAVINGS_H
#define HIGHINTERESTSAVINGS_H
#include "SavingsAccount.h"
#include
using namespace std;
class HighInterestSavings : public SavingsAccount{
public:
HighInterestSavings(string name, double initialBalance);
int getMinimumBalance();
void printStatement();
void withdraw(double amount, string statement);
void withdraw(double amount);
private:
int minimumBalance;
};
#endif /* HIGHINTERESTSAVINGS_H */
//HighInterestSavings.cpp
#include "HighInterestSavings.h"
HighInterestSavings::HighInterestSavings(string name, double
initialBalance) : SavingsAccount(name, initialBalance, 0.05)
{
minimumBalance = 2500;
}
int HighInterestSavings::getMinimumBalance()
{
return minimumBalance;
}
void HighInterestSavings::withdraw(double amount, string
statement)
{
if (amount + getMinimumBalance() <= getBalance())
{
bankAccount::withdraw(amount, statement);
}
else
{
addStatementLine(statement.append(" Overdraft. Below Minimum
Balance."), amount);
}
}
void HighInterestSavings::withdraw(double amount)
{
withdraw(amount, "Withdrawal");
}
void HighInterestSavings::printStatement()
{
bankAccount::deposit(getBalance() * getInterestRate(),
"Interest");
cout << "High Interest Savings Account Statement" <<
endl;
cout << "Name: " << getName() << endl;
cout << "Account Number: " << getAccountNumber()
<< endl;
cout << "Minimum Balance: " << getMinimumBalance()
<< endl;
cout << "Interest Rate: " << getInterestRate() * 100
<< "%" << endl << endl;
cout << getStatementString() << endl;
cout << "Final Balance: " << getBalance() << endl
<< endl;
}
//NoServiceChargeChecking.h
#ifndef NOSERVICECHARGECHECKING_H
#define NOSERVICECHARGECHECKING_H
#include "checkingAccount.h"
#include
using namespace std;
class NoServiceChargeChecking : public CheckingAccount {
public:
NoServiceChargeChecking(string name, double initialBalance);
void writeCheck(double amount, int checkNumber);
void printStatement();
void withdraw(double amount, string statement);
void withdraw(double amount);
double getInterestRate();
int getMinimumBalance();
protected:
NoServiceChargeChecking(string name, double initialBalance, int
minBalance, double interestRate);
private:
double interestRate;
int minimumBalance;
};
#endif /* NOSERVICECHARGECHECKING_H */
//NoServiceChargeChecking.cpp
#include "NoServiceChargeChecking.h"
#include
#include
NoServiceChargeChecking::NoServiceChargeChecking(string name,
double initialBalance) : checkingAccount(name,
initialBalance)
{
minimumBalance = 1000;
this->interestRate = 0.02;
}
NoServiceChargeChecking::NoServiceChargeChecking(string name,
double initialBalance, int minBalance, double interestRate) :
checkingAccount(name, initialBalance)
{
minimumBalance = minBalance;
this->interestRate = interestRate;
}
void NoServiceChargeChecking::writeCheck(double amount, int
checkNumber)
{
stringstream output;
output << "Check #" << checkNumber;
withdraw(amount, output.str());
}
void NoServiceChargeChecking::withdraw(double amount, string
statement)
{
if (amount + getMinimumBalance() <= getBalance())
{
bankAccount::withdraw(amount, statement);
}
else
{
addStatementLine(statement.append(" Overdraft. Below Minimum
Balance."), amount);
}
}
void NoServiceChargeChecking::withdraw(double amount)
{
withdraw(amount, "Withdrawal");
}
void NoServiceChargeChecking::printStatement()
{
bankAccount::deposit(getBalance() * getInterestRate(),
"Interest");
cout << "No Service Charge Checking Statement" <<
endl;
cout << "Name: " << getName() << endl;
cout << "Account Number: " << getAccountNumber()
<< endl;
cout << "Interest Rate: " << getInterestRate() * 100
<< "%" << endl;
cout << "Minimum Balance: " << getMinimumBalance()
<< endl << endl;
cout << getStatementString() << endl;
cout << "Final Balance: " << getBalance() << endl
<< endl;
}
int NoServiceChargeChecking::getMinimumBalance()
{
return minimumBalance;
}
double NoServiceChargeChecking::getInterestRate()
{
return interestRate;
}
//checkingAccount.h
#ifndef CHECKINGACCOUNT_H
#define CHECKINGACCOUNT_H
#include "bankAccount.h"
class CheckingAccount : public bankAccount {
public:
CheckingAccount(string name, double initialBalance);
virtual void writeCheck(double amount, int checkNumber) = 0;
private:
};
#endif /* CHECKINGACCOUNT_H */
//checkingAccount.cpp
#include "checkingAccount.h"
CheckingAccount::CheckingAccount(string name, double
initialBalance) : bankAccount(name, initialBalance)
{
}
//SavingsAccount.h
#ifndef SAVINGSACCOUNT_H
#define SAVINGSACCOUNT_H
#include "bankAccount.h"
#include
#include
using namespace std;
class SavingsAccount : public bankAccount
{
public:
SavingsAccount(string name, double initialBalance);
double getInterestRate();
void printStatement();
protected:
SavingsAccount(string name, double initialBalance, double
interestRate);
private:
double interestRate;
};
#endif /* SAVINGSACCOUNT_H */
//SavingsAccount.cpp
#include "SavingsAccount.h"
SavingsAccount::SavingsAccount(string name, double
initialBalance) : bankAccount(name, initialBalance)
{
interestRate = 0.03;
}
SavingsAccount::SavingsAccount(string name, double
initialBalance, double interestRate) : bankAccount(name,
initialBalance)
{
this->interestRate = interestRate;
}
double SavingsAccount::getInterestRate()
{
return interestRate;
}
void SavingsAccount::printStatement()
{
bankAccount::deposit(getBalance() * getInterestRate(),
"Interest");
cout << "Savings Account Statement" << endl;
cout << "Name: " << getName() << endl;
cout << "Account Number: " << getAccountNumber()
<< endl;
cout << "Interest Rate: " << getInterestRate() * 100
<< "%" << endl << endl;
cout << getStatementString() << endl;
cout << "Final Balance: " << getBalance() << endl
<< endl;
}
//ServiceChargeChecking.h
#ifndef SERVICECHARGECHECKING_H
#define SERVICECHARGECHECKING_H
#include "checkingAccount.h"
#include
using namespace std;
class ServiceChargeChecking : public CheckingAccount {
public:
ServiceChargeChecking(string name, double initialBalance);
void writeCheck(double amount, int checkNumber);
void printStatement();
private:
int checksWritten;
static const int CHECK_LIMIT = 5;
static const int SERVICE_CHARGE = 10;
};
#endif /* SERVICECHARGECHECKING_H */
//ServiceChargeChecking.cpp
#include "ServiceChargeChecking.h"
#include
#include
using namespace std;
ServiceChargeChecking::ServiceChargeChecking(string name, double
initialBalance) : CheckingAccount(name, initialBalance)
{
bankAccount::withdraw(SERVICE_CHARGE, "Service Charge");
checksWritten = 0;
}
void ServiceChargeChecking::writeCheck(double amount, int
checkNumber)
{
stringstream output;
if (++checksWritten <= CHECK_LIMIT)
{
output << "Check #" << checkNumber;
bankAccount::withdraw(amount, output.str());
}
else
{
output << "Maximum Limit of Checks Reached. Check # "
<< checkNumber << " bounced";
addStatementLine(output.str(), amount);
}
}
void ServiceChargeChecking::printStatement()
{
cout << "Service Charge Checking Statement" <<
endl;
cout << "Name: " << getName() << endl;
cout << "Account Number: " << getAccountNumber()
<< endl << endl;
cout << getStatementString() << endl;
cout << "Final Balance: " << getBalance() << endl
<< endl;
}
Receiving Error in SavingsAccount.h
17 5 C:\Users\adam.brunell\Documents\Classes\C++\Week4\SavingsAccount.h [Error] 'SavingsAccount::SavingsAccount(std::string, double, double)' is protected
In: Computer Science
This is a Java program that I am having trouble making.
1- Search for the max value in the linked list.
2- Search for the min value in the linked list.
3- Swap the node that has the min data value with the max one. (Note: Move the nodes to the new positions).
4- Add the min value and the max value and insert the new node
with the calculated value before the last node.
I already made a generic program that creates the linked list and
has the ability to add and remove from the list. I am not sure how
to create these generic methods though.
Below is my attempt to make the min finder, but it does not work and gives me an error on the bolded parts. It says "bad operand types for binary operator >".
LList.java below:
package llist;
/**
*
* @author RH
* @param <E>
*/
public class LList<E> {
Node head, tail;
int size;
public LList() {
size = 0;
head = tail = null;
}
public void addFirst(E element) {
Node newNode = new Node(element);
newNode.next = head;
head = newNode;
size++;
if (tail == null) {
tail = head;
}
}
public void addLast(E element) {
Node newNode = new Node(element);
if (tail == null) {
head = tail = newNode;
} else {
tail.next = newNode;
tail = tail.next;
}
size++;
}
public void insert(int index, E element) {
if (index == 0) {
addFirst(element);
} else if (index >= size) {
addLast(element);
} else {
Node current = head;
for (int i = 1; i < index; i++) {
current = current.next;
}
Node holder = current.next;
current.next = new Node(element);
current.next.next = holder;
size++;
}
}
public void remove(int e) {
if (e < 0 || e >= size) {
System.out.println("Out of bounds");
} else if (e == 0) {
System.out.println("Deleted " + head.element);
head = head.next;
size--;
} else if (e == size - 1) {
Node current = head;
Node holder;
for (int i = 1; i < size; i++) {
current = current.next;
}
System.out.println("Deleted " + current.element);
tail.next = current.next;
tail = tail.next;
size--;
} else {
Node<E> previous = head;
for (int i = 1; i < e; i++) {
previous = previous.next;
}
System.out.println("Deleted " + previous.next.element);
Node<E> current = previous.next;
previous.next = current.next;
size--;
}
}
public int largestElement() {
int max = 49;
while (head != null) {
if (max < head.next) {
max = head.next;
}
head = head.next;
}
return max;
}
public int smallestElement() {
int min = 1001;
while (head != null) {
if (min > head.next) {
min = head.next;
}
head = head.next;
}
return min;
}
public void print() {
Node current = head;
for (int i = 0; i < size; i++) {
System.out.println(current.element);
current = current.next;
}
}
}
Node.java below:
package llist;
/**
*
* @author RH
* @param <E>
*/
public class Node<E> {
E element;
Node next;
public Node(E data) {
this.element = data;
}
}
Driver.java below:
package llist;
import java.util.concurrent.ThreadLocalRandom;
/**
*
* @author RH
*/
public class Driver {
public static void main(String[] args) {
LList<Integer> listy = new LList();
// adds 10 random numbers to the linkedlist
for (int i = 0; i < 10; i++) {
listy.addFirst(ThreadLocalRandom.current().nextInt(50, 1000 +
1));
}
System.out.println("");
listy.print();
System.out.println("");
int max = listy.largestElement();
int min = listy.smallestElement();
System.out.println(max);
System.out.println(min);
//listy.remove(1);
//System.out.println("");
//listy.print();
}
}
I am not sure how to get these generic methods made.
In: Computer Science