Read in the names of several grocery items from the keyboard and create a shopping list using the Java ArrayList abstract data type.
Flow of Program:
1) Create a new empty ArrayList
2) Ask the user for 5 items to add to a shopping list and add them to the ArrayList (get from user via the keyboard).
3) Prompt the user for an item to search for in the list. Output a message to the user letting them know whether the item exists in the shopping list. Use a method that is part of the ArrayList class to do the search.
4) Prompt the user for an item to delete from the shopping list and remove it. (be sure to handle the case where they don’t want to delete anything). Use a method that is part of the ArrayList class to do the delete.
5) Prompt the user for an item to insert into the list. Ask them what they want to insert and where they want to insert it (after which item). Use a method that is part of the ArrayList class to do the insertion.
6) Output the final list to the user.
In: Computer Science
Part I: The Employee Class
You are to first update the Employee class to include two virtual functions. This will make the Employee class an abstract class.
* Update the function display() to be a virtual function
* Add function, double weeklyEarning() to be a pure virtual function. This will make Employee an abstract class, so your main will not be able to create any Employee objects.
Part II: The Derived Classes
Add an weeklyEarning() function to each of the three derived classes. A salaried employee’s weekly earning is as stored. An hourly employee’s weekly earning is the hrsworked * payperhr. A commissioned employee’s weekly earning would be the base + the comAmount.
Employee.h
-----------------------------------
#ifndef Employee_H
#define Employee_H
#include
using namespace std;
class Employee
{
private:
string lastName;
string firstName;
int idNum;
public:
Employee(); //default values assigned to all variables
Employee(int idNum, string lname, string fname);
void setLName(string);
void setFName(string);
void setIDNum(int);
string getLName();
string getFName();
int getIDNum();
void displayName();
void display();
};
#endif
-----------------------------------
-----------------------------------
Employee.cpp
-----------------------------------
#include
#include
#include"Employee.h"
using namespace std;
Employee::Employee() {
//default values assigned to all variables
lastName = "";
firstName = "";
idNum = 0;
}
Employee::Employee(int idNum, string lname, string fname) {
this->lastName = lname;
this->firstName = fname;
this->idNum = idNum;
}
//Sets last name
void Employee::setLName(string lname) {
this->lastName = lname;
}
//sets first name
void Employee::setFName(string fname) {
this->firstName = fname;
}
//sets id num
void Employee::setIDNum(int idnum) {
this->idNum = idnum;
}
//get last name
string Employee::getLName() {
return lastName;
}
//get first name
string Employee::getFName() {
return firstName;
}
//get id num
int Employee::getIDNum() {
return idNum;
}
//display id and last name
void Employee::displayName() {
cout << endl << "ID Num : " << this->idNum;
cout << endl << "Last name : " << this->lastName;
}
//display employee details
void Employee::display() {
cout << endl << "ID Number " << this->idNum;
cout << endl << "First name : " << this->firstName;
cout << endl << "Last name : " << this->lastName;
}
-----------------------------------
-----------------------------------
Salaried.h
-----------------------------------
#ifndef Salaried_H
#define Salaried_H
#include "Employee.h"
#include
using namespace std;
class Salaried : public Employee{
private:
double weeklySal;
public:
Salaried();
Salaried(int idNum, string lname, string fname);
Salaried(int idNum, string lname, string fname, double sal);
void setSal(double nsal);
double getSal();
void displaySal();
void display();
};
#endif
-----------------------------------
-----------------------------------
Salaried.cpp
-----------------------------------
#include "Salaried.h"
#include
using namespace std;
Salaried::Salaried():Employee() {
this->weeklySal = 0;
}
Salaried::Salaried(int idNum, string lname, string fname) :Employee(idNum, lname, fname) {
this->weeklySal = 0;
}
Salaried::Salaried(int idNum, string lname, string fname, double sal) : Employee(idNum, lname, fname) {
this->weeklySal = sal;
}
//set salary
void Salaried::setSal(double nsal) {
this->weeklySal = nsal;
}
//get salary
double Salaried::getSal() {
return weeklySal;
}
//display name, id num, salary
void Salaried::displaySal() {
cout << endl << "Name " << this->getLName();
cout << endl << "ID Num " << this->getIDNum();
cout << endl << "Weekly salary " << this->weeklySal;
cout << endl << "------------------------------";
}
//Display employee details
void Salaried::display() {
Employee::display();
cout << endl << "Weekly salary " << this->weeklySal;
cout << endl << "------------------------------";
}
-----------------------------------
-----------------------------------
Commission.h
-----------------------------------
#ifndef Commission_H
#define Commission_H
#include
#include "Employee.h"
using namespace std;
class Commission : public Employee{
private:
double basesalary;
double comAmount;
public:
Commission();
Commission(int idNum, string lname, string fname);
Commission(int idNum, string lname, string fname, double bsal);
void setBase(double npay);
void setCom(double nhr);
double getBase();
double getCom();
void displayBase();
void displayEmp();
};
#endif
-----------------------------------
-----------------------------------
Commission.cpp
-----------------------------------
#include "Commission.h"
#include
using namespace std;
//sets Commission instance to default intial values
Commission::Commission():Employee() {
this->basesalary = 0;
this->comAmount = 0;
}
//Sets Commission instance to Commission parameters
Commission::Commission(int idNum, string lname, string fname):Employee(idNum, lname, fname) {
this->basesalary = 0;
this->comAmount = 0;
}
//Sets Commission instance to Employee plus Commision parameters
Commission::Commission(int idNum, string lname, string fname, double bsal):Employee(idNum, lname, fname) {
this->comAmount = 0;
this->basesalary = bsal;
}
//Sets base salary
void Commission::setBase(double npay) {
this->basesalary = npay;
}
//Set commision salary
void Commission::setCom(double nhr) {
this->comAmount = nhr;
}
//Get base salary
double Commission::getBase() {
return basesalary;
}
//Get commission salary
double Commission::getCom() {
return comAmount;
}
//Display base salary and commision salary
void Commission::displayBase() {
cout << endl << "Name " << this->getLName();
cout << endl << "ID Num " << this->getIDNum();
cout << endl << "Base salary " << this->basesalary;
cout << endl << "------------------------------";
}
//Display commission employee details
void Commission::displayEmp() {
Employee::display();
cout << endl << "Base salary " << this->basesalary;
cout << endl << "Commission Amount : " << this->comAmount;
cout << endl << "------------------------------";
}
-----------------------------------
-----------------------------------
Hourly.h
-----------------------------------
#ifndef Hourly_H
#define Hourly_H
#include
#include"Employee.h"
using namespace std;
class Hourly : public Employee{
private:
double payperhr;
double hrsworked;
public:
Hourly();
Hourly(int idNum, string lname, string fname);
Hourly(int idNum, string lname, string fname, double newpay);
void setPay(double);
void setHrs(double nhr);
double getPay();
double getHrs();
void displayHrly();
void display();
};
#endif
-----------------------------------
-----------------------------------
Hourly.cpp
-----------------------------------
#include "Hourly.h"
#include
using namespace std;
Hourly::Hourly():Employee() {
this->payperhr = 0;
this->hrsworked = 0;
}
Hourly::Hourly(int idNum, string lname, string fname):Employee(idNum, lname, fname) {
this->payperhr = 0;
this->hrsworked = 0;
}
Hourly::Hourly(int idNum, string lname, string fname, double newpay): Employee(idNum, lname, fname) {
this->payperhr = newpay;
this->hrsworked = 0;
}
void Hourly::setPay(double pphr) {
this->payperhr = pphr;
}
void Hourly::setHrs(double nhr) {
this->hrsworked = nhr;
}
double Hourly::getPay() {
return payperhr;
}
double Hourly::getHrs() {
return hrsworked;
}
void Hourly::displayHrly() {
cout << endl << "Name " << this->getLName();
cout << endl << "ID Num " << this->getIDNum();
cout << endl << "Pay per hour " << this->payperhr;
cout << endl << "------------------------------";
}
void Hourly::display() {
Employee::display();
cout << endl << "Pay per hour " << this->payperhr;
cout << endl << "Hours worked : " << this->hrsworked;
cout << endl << "------------------------------";
}
In: Computer Science
Task 1: BetterHealth is a membership-based fitness club in Toronto. Customers can purchase a membership that provides a fixed number (e.g. 100) of free visits to the club upon registration. When the initial number of visits runs out, they can purchase additional visits as needed. All types of fitness equipment and all fitness classes offered in the club are open for this membership. Please write a Java program (Membership.java) for membership management.
The Membership class should have the following public interface:
1. public Membership(String name, int visits): A constructor to set up the member’s name and the initial number of visits allowed. The parameter visits is supposed to be positive (if not, initialize the number of visits to 0).
2. public String getName(): An accessor to return the member’s name.
3. public int getRemainingVisits(): An accessor to return the number of remaining visits.
4. public boolean isValid(): A method to decide if one’s membership is still valid (true if the number of remaining visits is greater than 0; false otherwise).
5. public boolean topUp (int additionalVisits): A method to add additional visits (represented by additionalVisits) to the remainingVisits. Returns true if the top-up succeeds and false otherwise. The top-up succeeds only If the given additionalVisits is non-negative.
6. public boolean charge(): A method that deducts 1 from the number of remaining visits when the membership is valid. Returns true if the charge succeeds and false otherwise. The charge succeeds only if the membership is valid before charging.
7. public boolean equipmentAllowed(): A method that indicates whether the equipment at the gym is available to this kind of membership. Returns true for now; to be updated in Task 2.
8. public boolean classesAllowed(): A method that indicates whether the fitness classes at the gym are available to this kind of membership. Returns true for now; to be updated in Task 2.
Write a tester program Task1MembershipTester to test the class you have written.
Follow the examples given in class (e.g., BankAccountTester), and create an objectfrom the class Membership above. Test the public interface of your class thoroughly (each public method must be tested at least once). For accessor methods, print out the expected return value and the return value of your method (see the BankAccountTester example) to compare. This tester class is not to be submitted for marking, but it is beneficial for you to make sure your Membership class works as intended.
Task 2: The club now introduces a new type of membership called PremiumMembership. It is valid within one year from the date of purchase for unlimited visits. Such members can use fitness equipment, but cannot attend fitness classes. In addition, pool access is available for this type of membership. Since now we have two types of memberships (and imagine down the road we might have more), you should implement a hierarchy of classes to represent the different types of membership. At the top of the hierarchy, you must define an abstract class called BaseMembership defining the methods common to different types of memberships. BaseMembership has the following public interface:
1. public BaseMembership(String name, String type): A constructor to set up the member’s name and member’s type.
2. public String getName(): An accessor to return the member’s name.
3. public String getType(): An accessor to return a string that represents the type of membership.
4. public abstract boolean isValid(): An abstract method that should be overridden in the subclasses.
5. public boolean equipmentAllowed(): Set an initial return value and override in the subclasses.
6. public boolean classesAllowed(): Set an initial return value and override in the subclasses.
You must then define classes StandardMembership and PremiumMembership that inherit from BaseMembership, defining additional methods as needed. StandardMembership should be implemented to model the type of membership in Task 1. The class PremiumMembership should have the following public interface:
1. public PremiumMembership(String name, String startDateString): A constructor to set up the member’s name and his start date. To transform startDateString to a Date type, a method stringToDate is provided in the hint below.
2. public boolean isValid(): A method to decide if one’s membership is still valid (If the current time is less than one year from the start time, it is valid). Please see the hint below.
3. public boolean equipmentAllowed(): Return true.
4. public boolean classesAllowed(): Return false.
5. public boolean poolAllowed(): Return true.
Hint: Java uses the number of milliseconds since January 1, 1970, 00:00:00 GMT to represent time/date. Use ‘new java.util.Date()’ to create a Date object of the current time in milliseconds. ‘System.currentTimeMillis()’ is used to get the current time in milliseconds; ‘getTime()’ is used to return the long milliseconds of a Date object; One year in milliseconds can be presented: long MILLIS_YEAR = 360 * 24 * 60 * 60 * 1000L;
/**
* Utility method to transform a string represented date to Date object.
* E.g., "2010-01-02" will be transformed to Sat Jan 02 00:00:00 GMT 2010
*/
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public static Date stringToDate(String dateString) {
DateFormat f = new SimpleDateFormat("yyyy-MM-dd");
Date date = null;
try {
date= f.parse(dateString);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}Similarly, write a tester program Task2MembershipTester to test the classes you
have written in Task 2. Create objects from the classes StandardMembership and
PremiumMembership above. This tester class is not to be submitted.
In: Computer Science
Using Java
Write only “stubs” for methods in the Figure, Rectangle, and Triangle classes:
Consider a graphics system that has classes for various figures — say, rectangles, boxes, triangles, circles, and so on. For example, a rectangle might have data members’ height, width, and either a center point or upper-left corner point, while a box and circle might have only a center point (or upper-right corner point) and an edge length or radius, respectively. In a well-designed system, these would be derived from a common class, Figure. In this homework assignment, you will implement such a system.
The class Figure is an abstract base class. In this class, create abstract methods for draw, erase, center, equals, and toString.
Add Rectangle and Triangle classes derived from Figure. Each class has stubs for methods erase, draw, and center. In these "stubs", the method simply prints a message telling the name of the class and which method has been called in that class. Because these are just stubs, they do nothing more than output this message. The method center calls the erase and draw methods to erase the object at its current location and redraw the figure at the center of the picture being displayed. Because you have only stubs for erase and draw, center will not do any real “centering” but simply will call the methods erase and draw, which will allow you to see which versions of draw and center it calls. Add an output message in the method center that announces that center is being called. The methods should take no arguments.
Define a demonstration program for your classes which contains main. Test your programs:
In main, make sure that you tell the user what's going on at each step.
Your output should consist primarily of messages from your stub methods. An example of the output from your program might be the following (note: output from main method is shown below in italics):
** Create 2 triangles ** Entering Figure Constructor for triangle 0 Running Triangle constructor for triangle 0 Entering Figure Constructor for triangle 1 Running Triangle constructor for triangle 1 ** Create 2 rectangles ** Entering Figure Constructor for rectangle 0 Running Rectangle constructor for rectangle 0 Entering Figure Constructor for rectangle 1 Running Rectangle constructor for rectangle 1 ** Draw both triangles ** Entering draw() method for Triangle 0 Entering draw() method for Triangle 1 ** Draw both rectangles ** Entering draw() method for Rectangle 0 Entering draw() method for Rectangle 1 ** Center one triangle ** Entering center() method for Triangle 0 center() calling erase() Entering erase() method for Triangle 0> center() calling setCenter() to reset center. Entering Figure's setCenter() for figure 0 center() calling draw() Entering draw() method for Triangle 0 ** Center one rectangle ** Entering center() method for Rectangle 1 center() calling erase() Entering erase() method for Rectangle 1 center() calling setCenter() Entering Figure's setCenter() for figure 1 center() calling draw() Entering draw() method for Rectangle 1 |
In: Computer Science
Apply the nursing Process to the following
Hypothetical situation
Mrs. Rojas, 30 years old, came to the emergency room with a cold
two weeks ago, she presented dyspnea (difficulty breathing). It
indicates that you have a fever, headache for several days, chest
pain, and you have to sit up to breathe well. Also, complaints of
chills have decreased fluid intake 2 days ago. On physical
examination temp. 39.5C, pulse 92 reg., Strong, Resp. 22 / min.
Superficial. B / P 122/80., Dry mouth mucosa, pale, hot skin,
reddened cheeks. Decreased vesicular and crackling sounds on
inspiration in the right upper and lower lobe. Its thoracic
expansion is 3 cm., Scant cough, dense sputum of light pink color.
Lethargic, weak, and fatigued appearance. The doctor suspects that
this may have the diagnosis Influenza A H1N1.
After reading the situation, answer the following questions;
1.After reading and analyzing the situation, identify the estimated
data, and classify them as subjective and objective.
2. Mention the problems that you infer in this situation?
3. According to the NANDA category, which nursing diagnosis applies in this situation. (It must include Problem, etiology and symptoms).
4. Develop the expected result for this Situation
5.Develop nursing interventions such as coordinating and
managing
Care of this patient, include the nursing orders and justification
for each intervention. (Complete the table).
Nursing
orders Justification
6. Mention what legal ethical implications should be considered in this condition.
7. List and define the six nursing steps and define them.
outcome
Care providers to individuals in different settings,
understanding cultural variations, effective communication based on
their learning style.
Coordinator and care manager in situations that require
problem-solving and uses principles of delegation when
warranted.
Practice the profession according to the legal framework of the
profession's standards.
Uses the nursing process as a framework to develop, implement, and
evaluate the care plan for the healthy individual or with a minimum
of alterations.
Information management.
In: Nursing
Write a C# console program that continually asks the user "Do you want
to enter a name (Y/N)? ". Use a "while" loop to accomplish this. As long as the user enters
either an upper or lowercase 'Y', then prompt to the screen "Enter First and Last Name: " and
then get keyboard input of the name. After entering the name, display the name to the screen.
---
Create a Patient class which has private fields for patientid, lastname,
firstname, age, and email. Create public data items for each of these private fields with get and
set methods. The entire lastname must be stored in uppercase. Create a main class which
instantiates a patient object and sets values for each data item within the class. Display the
data in the object to the console window.
---
Modify the Patient class with two overloaded constructors: A new default
constructor which initializes the data items for a patient object using code within the
constructor (use any data). A second constructor with parameters to pass all the data items
into the object at the time of instantiation. Create a test main class which instantiates two
objects. Instantiate the first object using the default constructor and the second object using
the constructor with the parameters.
---
Modify the main class in the patient application to include a display
method that has a parameter to pass a patient object and display its content.
---
Modify the patient class with two overloaded methods to display a bill for a
standard visit based on age. In the first method do not use any parameters to pass in data. If
the patient is over 65, then a standard visit is $75. If the patient is under 65, then the standard
doctors office visit is $125. Build a second method where you pass in a discount rate. If the
patient is over 65, then apply the discount rate to a standard rate of $125. Create a main
method that calls both of these methods and displays the results.
-----
Create two subclasses called outpatient and inpatient which inherit from
the patient base class. The outpatient class has an additional data field called doctorOfficeID
and the inpatient class has an additional data item called hospitalID. Write a main method that
creates inpatient and outpatient objects. Sets data for these objects and display the data.
---
Modify the base class of Problem 5 to be an abstract class with an abstract
display method called displayPatient that does not implement any code. Create specific
implementations for this method in both the outpatient and inpatient subclasses
In: Computer Science
Insurance companies know the risk of insurance is
greatly reduced if the company insures not just one person, but
many people. How does this work? Let x be a random
variable representing the expectation of life in years for a
25-year-old male (i.e., number of years until death). Then the mean
and standard deviation of x are μ = 48.7 years
and σ = 10.3 years (Vital Statistics Section of the
Statistical Abstract of the United States, 116th
Edition).
Suppose Big Rock Insurance Company has sold life insurance policies
to Joel and David. Both are 25 years old, unrelated, live in
different states, and have about the same health record. Let
x1 and x2be random
variables representing Joel's and David's life expectancies. It is
reasonable to assume x1 and
x2 are independent.
Joel, x1: 48.7; σ1 =
10.3
David, x2: 48.7; σ1 =
10.3
If life expectancy can be predicted with more accuracy, Big Rock will have less risk in its insurance business. Risk in this case is measured by σ (larger σ means more risk).
(a) The average life expectancy for Joel and David is W = 0.5x1 + 0.5x2. Compute the mean, variance, and standard deviation of W. (Use 2 decimal places.)
| μ | |
| σ2 | |
| σ |
(b) Compare the mean life expectancy for a single policy (x1) with that for two policies (W).
The mean of W is larger.The means are the same. The mean of W is smaller.
(c) Compare the standard deviation of the life expectancy for a
single policy (x1) with that for two policies
(W).
The standard deviation of W is smaller.The standard deviation of W is larger. The standard deviations are the same.
In: Statistics and Probability
Insurance companies know the risk of insurance is greatly reduced if the company insures not just one person, but many people. How does this work? Let x be a random variable representing the expectation of life in years for a 25-year-old male (i.e., number of years until death). Then the mean and standard deviation of x are μ = 52.4 years and σ = 12.1 years (Vital Statistics Section of the Statistical Abstract of the United States, 116th Edition).
Suppose Big Rock Insurance Company has sold life insurance policies to Joel and David. Both are 25 years old, unrelated, live in different states, and have about the same health record. Let x1 and x2 be random variables representing Joel's and David's life expectancies. It is reasonable to assume x1 and x2 are independent.
Joel, x1: 52.4; σ1 = 12.1 David, x2: 52.4; σ2 = 12.1
If life expectancy can be predicted with more accuracy, Big Rock will have less risk in its insurance business. Risk in this case is measured by σ (larger σ means more risk). (a) The average life expectancy for Joel and David is W = 0.5x1 + 0.5x2. Compute the mean, variance, and standard deviation of W. (Use 2 decimal places.)
μ
σ2
σ
(b) Compare the mean life expectancy for a single policy (x1) with that for two policies (W).
The mean of W is larger.
The means are the same.
The mean of W is smaller.
(c) Compare the standard deviation of the life expectancy for a single policy (x1) with that for two policies (W).
The standard deviation of W is smaller.
The standard deviations are the same.
The standard deviation of W is larger.
In: Statistics and Probability
Insurance companies know the risk of insurance is greatly reduced if the company insures not just one person, but many people. How does this work? Let x be a random variable representing the expectation of life in years for a 25-year-old male (i.e., number of years until death). Then the mean and standard deviation of x are μ = 52.5 years and σ = 10.1 years (Vital Statistics Section of the Statistical Abstract of the United States, 116th Edition). Suppose Big Rock Insurance Company has sold life insurance policies to Joel and David. Both are 25 years old, unrelated, live in different states, and have about the same health record. Let x1 and x2 be random variables representing Joel's and David's life expectancies. It is reasonable to assume x1 and x2 are independent.
Joel, x1: 52.5; σ1 = 10.1 David, x2: 52.5; σ1 = 10.1
If life expectancy can be predicted with more accuracy, Big Rock will have less risk in its insurance business. Risk in this case is measured by σ (larger σ means more risk).
(a) The average life expectancy for Joel and David is W = 0.5x1 + 0.5x2. Compute the mean, variance, and standard deviation of W. (Use 2 decimal places.) μ σ2 σ
(b) Compare the mean life expectancy for a single policy (x1) with that for two policies (W). The mean of W is smaller. The mean of W is larger. The means are the same.
(c) Compare the standard deviation of the life expectancy for a single policy (x1) with that for two policies (W). The standard deviation of W is larger. The standard deviation of W is smaller. The standard deviations are the same.
In: Statistics and Probability
Public financial management is critical for successful
delivery of public services. The prime
objective of public financial management is to ensure that public
resources allocated to projects
and programmes through covered entities are applied economically,
efficiently and effectively
to enhance value for money in public spending. Contrary to
expectation, public financial
management in Ghana is bedevilled with gross infractions,
irregularities and malpractices
which deny the citizens the quality of public service delivery they
deserve. The current Auditor
General’s Report on Public Accounts of the central government
agencies, the local
governments and educational institutions reveal that several
millions of Ghana Cedis is lost to
financial impropriety and malpractices. This has been on the
increase over the years. surely,
these occurrences should attract policy attention.
Ghana Moni is a Civil Society Organisation with the prime aim of
demanding and promoting
accountability in Ghana. Ghana Moni is organising an essay writing
competition for Final Year
Accountancy Students in all Universities in Ghana on the topic:
Accounting for Financial
Impropriety in Public Financial Management in Ghana. The aim of the
competition is to
gather fresh and further evidence on the causes and practical
remedies of the persistent misuse
of public resources. The award for winners is GHS100,000.00. The
deadline for submission is
48 hours from now.
Required:
Make your entry into the competition in strict compliance with
these requirements:
i) Abstract (Not exceeding 100 words)
ii) Introduction (Not exceeding 200 words)
iii) Taxonomy of financial impropriety3
(Not exceeding 300 words)
iv) Causes of financial impropriety in the public sector (Not
exceeding 600 words)
v) Practical remedies of financial impropriety (Not exceeding 600
words)
vi) Conclusion (Not exceeding 100 words)
In: Economics