Question by "engineering"

103,744 questions

All "Engineering" Questions

The objective of the lab is to take the UML Class diagram and enhance last week's Employee class by making the following changes:

Create a class called Salaried that is derived from Employee.
Create a class called Hourly that is also derived from Employee.
Since all classes/objects inherit from the System.Object class, change the appropriate "DisplayClass" information method to override the System.Object.ToString()method.
Override the base class CalculatePay method

STEP 1: Understand the UML Diagram
Notice the change in UML diagram. It is common practice to leave out the properties or (accessors and mutators - getters and setters) from UML class diagrams, sincethere can be so many of them. Unless otherwise specified, it is assumed that there is a property or accessor (getter) and a mutator (setter) for every classattribute.

STEP 2: Create the Project
You will want to use the Week 4 project as the starting point for the lab. Before you move on to the next step, build and execute the Week 5 project.
Week4 Project
class Program
static void Main(string[] args)

Employee emp = new Employee();

Console.Write("Enter first name: ");
string first = Console.ReadLine();
Console.Write("Enter last name: ");
string last = Console.ReadLine();
Console.Write("Gender: ");
char gen = Console.ReadLine().First();
Console.Write("Dependents: ");
string dep = Console.ReadLine();
Console.Write("Annual Salary: $");
string salary = Console.ReadLine();
Console.Write("Enter health insurance (Full or Partial): ");
string health = Console.ReadLine();
Console.Write("Enter life insurance :$ ");
double life = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter vacation: ");
int vacation = Convert.ToInt32(Console.ReadLine());

emp.FirstName = first;
emp.LastName = last;
emp.Gender = gen;





Console.WriteLine("Total employees : {0}n", Employee.GetNumberOfEmployees());

Benefit benefit1 = new Benefit("Full", 1000, 5);

Employee emp2 = new Employee("Mary", "Noia", 'F', 5, 24000.0, benefit1);

Console.WriteLine("Total employees : {0}n", Employee.GetNumberOfEmployees());

class Employee : IEmployee

private string firstName;
private string lastName;
private char gender;
private int dependents;
private double annualSalary;

private static int numEmployees = 0;

public Benefit benefit;

public Employee()
firstName = "not given";
lastName = "not given";
gender = 'U';
dependents = 0;
annualSalary = 20000;

benefit = new Benefit("not given", 0, 0);

public Employee(string first, string last, char gen, int dep, double salary, Benefit benefit)
firstName = first;
lastName = last;
gender = gen;
dependents = dep;
annualSalary = salary;

this.benefit = new Benefit(benefit.GetHealthInsurance(), benefit.GetLifeInsurance(), benefit.GetVacation());

public double CalculatePay()
return annualSalary / 52;

public void DisplayEmployee()
Console.WriteLine("***************** Employee Information *****************");
Console.WriteLine("First Name: {0}", firstName);
Console.WriteLine("Last Name: {0}", lastName);
Console.WriteLine("Gender: {0}", gender);
Console.WriteLine("Dependents: {0}", dependents);
Console.WriteLine("Annual Salary: {0:c}", annualSalary);
Console.WriteLine("Weekly Pay: {0:c}", CalculatePay());

public string FirstName
firstName = value;
return firstName;

public string LastName
lastName = value;
return lastName;

public char Gender
gender = value;
return gender;

public int Dependents
dependents = value;
return dependents;

public double AnnualSalary
annualSalary = value;
return annualSalary;

public void SetDependents(int dep)
dependents = dep;

public void SetAnnualSalary(double salary)
annualSalary = salary;

public static int GetNumberOfEmployees()
return numEmployees;

public void SetDependents(string dep)
dependents = Convert.ToInt32(dep);

public void SetAnnualSalary(string salary)
annualSalary = Convert.ToDouble(salary);
interface IEmployee

double CalculatePay();


class Benefit

private string healthInsurance;

private double lifeInsurance;

private int vacation;

public Benefit()


public Benefit(string health, double life, int v)

healthInsurance = health;

lifeInsurance = life;

vacation = v;


public void DisplayBenefits()

Console.WriteLine("Health Insurance: {0}", healthInsurance);

Console.WriteLine("Life Insurance: {0}", lifeInsurance);

Console.WriteLine("Vacation: {0}", vacation);


public void SetHealthInsurance(string health)

healthInsurance = health;


public string GetHealthInsurance()

return healthInsurance;


public void SetLifeInsurance(double life)

lifeInsurance = life;


public double GetLifeInsurance()

return lifeInsurance;


public void SetVacation(int v)

vacation = v;


public int GetVacation()

return vacation;



STEP 3: Modify the Benefits Class
Change the DisplayBenefits method to override the System.Object.ToString method, ensuring that the method returns a string, and does not explicitly display theinformation, but just returns a string.
STEP 4: Modify the Employee Class

Using the updated Employee class diagram, modify the attributes so that they become protected.
Change the name of the DisplayEmployee method to "ToString", which then overrides the System.Object.ToString() method, and returns a string.
Delete the IEmployee interface, and remove the reference from the Employee class
STEP 5: Create the Salaried Class

Using the UML Diagrams from Step 1, create the Salaried class, ensuring to specify that the Salary class inherits from the Employee class.
For each of the constructors listed in the Salaried class ensure to invoke the appropriate super class constructor and pass the correct arguments to the super classconstructor. This will initialize the protected attributes and update the numEmployees counter
The valid management levels are 0, 1, 2, and 3, and should be implemented as a constant.
Override the CalculatePay method to add a 10 percent bonus to the annualSalary depending on the management level. The bonus percent is a fixed 10 percent, and shouldbe implemented as a constant. However, depending on the management level the actual bonus percentage fluctuates (i.e., actualBonusPercentage = managementLevel *BONUS_PERCENT).
Override the ToString method to add the management level to the employee information.
STEP 6: Create the Hourly Class

Using the UML Diagrams from Step 1, create the Hourly classes, ensuring to specify that the Hourly class inherits from the Employee class.
For each of the constructors listed in the Hourly class ensure to invoke the appropriate super class constructor and pass the correct arguments to the super classconstructor. This will initialize the protected attributes and update the numEmployees counter.
The valid category types are "temporary", "part time", "full time";
The provided hours must be more than 0 hours and less than 50 hours, and the limits should be implemented as constants.
The provided wage must be between 10 and 75, and the limits should be implemented as constants.
Override the CalculatePay method by multiplying the wages by the number of hours.
Override the ToString method to add the category to the hourly employee information.
If you haven't done so already, make sure you identify the appropriate place(s) in the Hourly class to set the annualSalary attribute to a proper value (call theCalculatePay method to get the weekly pay and multiply the result by 52 in order to calculate and set the annualSalary).
STEP 7: Construct the Main Method

Create an array of type Employee and size 3. Create 3 new objects, one Employee, one Hourly and one Salaried in positions 0, 1 and 2 of the array respectively. Use anyconstructors you wish except the default.
Using a FOR loop, iterate through the array and call the ToString and CalculatePay methods of each object to display the weekly pay and the employee's informationrespectively.
Call the GetNumEmployees method to display the total number of employees instantiated.
STEP 8: Compile and Test

The output of your program should resemble the following:

On-screen output display:
Welcome the Employee Hierarchy Program
CIS247, Week 5 Lab
Name: Solution

This program tests an Employee inheritance hierarchy

*********************** Display Employee's Data **********************

Employee Type


First Name


Last Name






Annual Salary


Weekly Pay


Health Insurance


Life Insurance




*********************** Display Employee's Data ********************** Employee Type


First Name


Last Name




Management Lv1.


Annual Salary


Weekly Pay


Health Insurance


Life Insurance




*********************** Display Employee's Data **********************

Employee Type


First Name


Last Name







part time





Weekly Pay


Annual Salary


Health Insurance


Life Insurance




total Number of Employess in Database: 3

Press the ESC key to close the image description and return to lecture

Image Description

Seen 2 years ago Claude x 1 answers

public static double[][] trainNetwork(double[][] trainingSet,

double[][] kernelSet, double variance, int nClassifications, double learningRate, int nIterations, Random rng){

//Create a new 2D array of weights
//number of rows: the number of classifications
//number of cols: one larger than the number of rows in the KernelSet

//Initialize your new weights array with random doubles in the range
//-1.0 inclusive to +1.0 exclusive

//Create a new 2D array of inputs for the perceptrons
//number of rows: the length of the training set
//number of cols: same as the number of cols in your weights array

//Assign each row of your new inputs array with the row returned
//by the calcPerceptronInput called on each example in the training set.

//Main training algorithm.
//Repeat for the given number of iterations
// Repeat for each example in the training set
// Set perceptron_classification to the result from classifyInput using
// this training set example's corresponding perceptron input (determined above)
// Repeat for each possible_classification: 0 to nClassifications - 1
// Determine the target value (1 or -1): target is 1 if possible_classification
// is equal to the actual classification of the example. Otherwise, it is -1.
// Determine the output value: output is 1 if the perceptron_classification
// is equal to the possible classification. Otherwise, it is -1.
// Repeat for each weight of the possible_classification
// Increase the weight by the learning rate times (the target minus the output)
// times the perceptron input value for this training set example and weight

//Replace the line below to return your weights array.
return null;

Please help me write the script in bewteen.

Seen 2 years ago Oscar Rhys 2 answers

1. (12pts) What are the class type, netid and the hostid in the following class-ful IP addresses in decimal?






2. (6pts) A Class A network uses 11 bits for a subnet id.
a. How many possible subnets are there?

b. How many bits will be in the hostid?

c. How many possible valid hosts are there on each subnet?

d. What is the mask in binary notation?

3. (8pts) We wish to assign a CIDR block of 1024 addresses (including all 0’s and all 1’s), starting at
a. What is the maximum address in this block? ? [Hint: figure out how many bits are required to represent 1024 hosts. The maximum address is when all those bits are1]

b. How many bits are in the host_id?

c. How many bits are in the net_id?

d. What is the mask in binary, dotted decimal, and slash notation?

4. (6pts) A CIDR block extends from to
a. How many bits are in the net id?

b. How many bits are in the host id?

c. What is the mask in binary, dotted decimal and slash notation?

5. (10pts) Assume that NJIT has a CIDR address space Which of the following addresses could be host addresses within that space? If the address isnot in the space, please provide an explanation why not for full credit.






6. (8pts)An ISP has CIDR block The ISP wants to create 9 sub-blocks from this block.
a. How many bits should the ISP add to the mask for the subblocks?

b. What is the maximum number of hosts in each subblock?

Seen 1 years ago Emily Elizabeth 0 answers

Write a Circle class that has the following data members:

1. radius: a double
2. pi: a double initialized with the value3.1416
3. The class should have the following member functions:

-Default constructor: a default constructor that sets radius to 0.0.
-Constructor. Accepts the radius of the circle as an argument
-setRadius (int). A mutator function for the radius variable.
-intgetRadius. An accessor function for the radius variable.
-inputRadius - from the keyboard
-displayCircle - In this object function you need tocall the function getArea to calculate the area of a circle, -then display the radius of a circle and its area - format: Radius: ______, Area= ______ .
-getArea. Return the area of the circle, which is calculated as area = pi * radius * radius
-getDiameter. Return the diameter of the circle, which iscalculated as diameter = radius *2
-getCircumference. Return the circumference of the circle, which is calculated as circumference = 2 * pi*     radius. 
-Write a program the demonstrate the Circle class perform the following tasks:

1. Create a Circle object called C1 with radius equal to zero.
2. Create a Circle object called C2 with radius equal to 5.0
3. Input theradius for the circle C1. Enter a value of 3.0 for the radius of the Circle C1.
4. Display the area of the circle C2 by calling the function getArea.
5. Display the diameter of the circle C2 by calling the function getDiameter.
6. Display the radius and area of the circle C1 by calling thefunction displayCircle.
7. Change the radius of the circle C1 to 10.0.
8. Display the circumference of the circle C1 by calling the functiongetCircumference..

Seen 1 years ago Nathaniel bag 0 answers

Seen 2 years ago Lam Williams 1 answers

Seen 1 years ago Gelbero Wilson 1 answers

Program Description: Basic User Interface
This program creates the basic user interface code that can be used in the following week’s iLab assignments. The assignment will help you get started using theprogramming environment and some practice with coding. You will also be able to re-use much, if not all, of the code in later assignments.
In this program, you will create the following methods:
1. displayApplicationInformation, which will provide the program user some basic information about the program.
2. displayDivider, which will provide a meaningful output separator between different sections of the program output.
3. getInput, which is a generalized function that will prompt the user for a specific type of information, then return the string representation of the userinput.
4. terminateApplication, which provides a program termination message and then terminates the application.
Using these methods, you will construct a program that prompts the user for the following:
1. Their name, which will be a string data type
2. Their age, which will be an integer data type
3. The gas mileage for their car, which will be a double data type
4. Display the collected information
Also, note that the program should contain a well documented program header.
//Program Header
//Program Name: Basic User Interface
//Programmer: Your Name
//CIS247, Week 1 Lab
Start main
//declare variables
input as string
name as string
age as integer
mileage as double
call displayApplicationInformation
call displayDivider(“Start Program”)
call displayDivider(“Get Name”)
set name = getInput(“Your Name”)
display “Your name is: “ + name
call displayDivider(“Get Age”)
set input = getInput(“Your Age”)
set age = convert input to integer
display “Your age is: “ + age
call displayDivider(“Get Mileage”)
set input = getInput(“Gas Mileage”)
set mileage = convert input to double
display “Your car MPG is: “ + mileage
call terminateApplication
end main program
procedure displayApplicationInformation
display “Welcome the Basic User Interface Program”
display “CIS247, Week 1 Lab”
display “Name: YOUR NAME”
display “This program accepts user input as a string, then makes the appropriate data conversion and displays the results”
end procedure
procedure displayDivider(string outputTitle)
display “**************** “ + outputTitle + “****************”
end procedure
function getInput(string inputType) as string
strInput as string
display “Enter the “ + inputType
get strInput
return strInput
end function
procedure terminateApplication
display “Thank you for using the Basic User Interface program”
exit application
end procedure

Seen 1 years ago Charlie Kyle 1 answers

Question:-Design a “good” entity-relationship diagramthat describes the following objects in an university application:students, instructors, professors, and courses.Students aresubdivided into graduate and undergraduate students. Students takea course in a particular semester and receive a grade for theirperformance. Sometimesstudents take the same course again in adifferent semester. There are no limits on how many courses astudent can take, and on how many students completed aparticularcourse. Each graduate student has exactly one advisor, who must bea professor, whereas each professor is allowed to be the advisor ofat most 20 students.Courses have a unique course number and acourse title. Students and professors have a name and a unique ssn;students additionally have a gpa; moreover, graduatestudents havea GRE-score, and undergraduate students have a single or multiplemajors. Professors can be students and take courses, but graduatestudents cannot beundergraduate students.a)Draw an entity-relationship model to represent thelibrary.b)Indicate the cardinalities for eachrelationshiptype;c) assign roles (role names) to each relationshipif thereare ambiguitiesd) Use sub-types, if helpful toexpressconstraints.Purposes:Ensure that you can analyze existing manual system and can drawEntity Relationship Diagrams (ERD) of any proposed system.Before Starting:An Entity Relationship DiagramThe entity relationship enables a software engineer to fully tofully specify the data objects that are input and output from asystem the attributes that define theproperties of these objects,and their relationshipsGuidelines to make ERDThe ERD is constructed in an iterative manner. The followingapproach is taken.1.During requirement elicitation, customer are asked to list the“things” that the application or business processaddresses. These “things” evolve into a list ofinputand output data objects as well as external entities that produceor consume information.2. Taking the objects one at a time, the analyst and customerdefine whether or not a connection exists between the data objectsand other objects.3.Whether a connection exists, the analyst and the customercreate one ore more object/relationship pairs.4. For each object/relationship pair, cardinality andmodality are explored.. Steps 2 through 4 are continued iteratively until allobject/relationships have been defined. It is common to discoveromissions as this process continues. Newobjects and relationshipswill invariably be added as the number of iterations grows.The attributes of each entity are defined.An entity relationship diagram is formalized and reviewed.Steps 1 through 7 are repeated until data modeling iscomplete.

Seen 2 years ago Olivia Patricia 1 answers

I need to reverse engineer from machine code to C, how do I do it?

This problem will give you a chance to reverse engineer a switch statement from
machine code. In the following procedure, the body of the switch statement has
been removed:

1 int switch_prob(int x, int n)
2 {
3 int result = x;
5 switch(n) {
7 /* Fill in code here */
8 }
10 return result;
11 }
Figure 3.44 shows the disassembled machine code for the procedure. We can
see in lines 4 and 5 that parameters x and n are loaded into registers %eax and
%edx, respectively.
The jump table resides in a different area of memory. We can see from the
indirect jump on line 9 that the jump table begins at address 0x80485d0. Using
the gdb debugger, we can examine the six 4-byte words of memory comprising
the jump table with the command x/6w 0x80485d0. gdb prints the following:
(gdb) x/6w 0x80485d0
0x80485d0: 0x08048438 0x08048448 0x08048438 0x0804843d
0x80485e0: 0x08048442 0x08048445
Fill in the body of the switch statement with C code that will have the same
behavior as the machine code.
1 08048420 :
2 8048420: 55 push %ebp
3 8048421: 89 e5 mov %esp,%ebp
4 8048423: 8b 45 08 mov 0x8(%ebp),%eax
5 8048426: 8b 55 0c mov 0xc(%ebp),%edx
6 8048429: 83 ea 32 sub $0x32,%edx
7 804842c: 83 fa 05 cmp $0x5,%edx
8 804842f: 77 17 ja 8048448
9 8048431: ff 24 95 d0 85 04 08 jmp *0x80485d0(,%edx,4)
10 8048438: c1 e0 02 shl $0x2,%eax
11 804843b: eb 0e jmp 804844b
12 804843d: c1 f8 02 sar $0x2,%eax
13 8048440: eb 09 jmp 804844b
14 8048442: 8d 04 40 lea (%eax,%eax,2),%eax
15 8048445: 0f af c0 imul %eax,%eax
16 8048448: 83 c0 0a add $0xa,%eax
17 804844b: 5d pop %ebp
18 804844c: c3 ret

Seen 1 years ago Roy Taylor 1 answers

Please Help. I've included both the question of the program and the part that I have completed and I need help real bad to complete the rest. Part A thru J arecompleted, can someone finish the rest, the highlighted areas. What I have included does compile. Below is the question of the program and after is the part I'vedone. There are 2 more posts related to this and I will award lifesaver ratings to those also.

Write a inventory program that will manage an inventory of videos owned by the store that buys videos from a wholesaler and then sells them and rents them tocustomers. It will now also manage a list of customers that are renting the videos.

A) Each video record will manage a name , a code number (unique), a quantity owned by the store, a quantity that are currently rented out and a quantity that havebeen sold.
B) The program will accept the following commands listed below:
C) HELP will list the commands.
D) QUIT will end the program.
E) BUY will prompt the user for a name, code and quantity bought by the store. It will then add the new item to the inventory. (This command is used the first timea specific video is bought by the store from the wholesaler.)
F) REBUY will prompt the user for a code and a quantity bought by the store. It will then add this quantity to the amount owned by the store. (This command is usedwhen the store buys additional videos for an item that it has previously bought from the wholesaler.)
G) RENT will prompt the user for a code and will then increase (by one) the quantity of the number rented out for that video provided that a video is available.Otherwise it will print a polite message saying that no videos are currently available.
H) SELL will prompt the user for a code and will then decrease (by one) the quantity of the number owned by the store and increase (by one ) the number soldprovided that a video is available. Otherwise it will print a polite message saying that no videos are currently available.
I) REPORT will neatly display a list all the videos on the screen. For each video listed there will be a name, code, quantity owned by the store, a quantity rentedout, a quantity sold and a quantity available for sale or rent.
J) TEST will generate and add 10 random videos to the inventory with appropriate values for all the information on each video. Each of these new videos will have arandom name with 3 letters.
K) You will add a new class called Person. Each Person will have a string name and a string phoneNumber and a string address.
L) You will add a new class called Renter which will inherit from Person as described in class. Each renter will have a unique ID number and avector of integers for keeping track of the video codes of the videos that they have currently rented out.
M) The new command ADD_RENTER will allow a new Renter of videos to be added to the system. Each renter will have a string name, a string phonenumber, a string address and a integer id number. The command will prompt for each of these fields.
N) The new command REPORT2 will neatly display on the screen the list of all the renters sorted by the renter’s code number. The display will showtheir ID number followed by the name followed by their phone number. (All on one line.) Indented underneath this line will be listed all of the videos that he orshe has currently rented out. Each video in this sub list will include the Code number of the video and the
name of the video. For Example the REPORT2 could display something that looks like this:
Renter IDNumber Name Phone number
0000146 John Doe 555-555-5555
Video IDNumber 0000002 Road Trip
Video IDNumber 0008523 Wine Tasting for Dummies

Renter IDNumber Name Phone number
0007412 Jane Doe 210-555-5555
Video IDNumber 0008523 Wine Tasting For Dummies
VIdeo IDNumber 0008745 Jaws

Renter IDNumber Name Phone number
0002548 John Smith 718-555-5555

Renter IDNumber Name Phone number
0009874 Mary Poppins 866-555-5555
Video IDNumber 0008523 Wine Tasting For Dummies
Video IDNumber 0008745 Jaws

O) The RENT command will also prompt the user for the ID number of the renter. It will also add the Video’s Code number to the list of videosrented out by the specified renter. It will create a polite error message if the entered ID or Code numbers are not valid.
P) The RETURN command will prompt for a Video Code Number and a Renter ID Number and in the Video’s record it will reduce the number rented out byone and in the Renter’s record will remove the Video’s ID from the list of rented records. It will create a polite error message if the entered ID or Code numbersare not valid or if the renter specified has not rented out the video specified.
Q) The class VideoStore will be persistent.
R) You will provide in the same directory as your sln file a file called CriteriaNotMet.txt where you will list the criteria in this assignmentthat you have not met on a single line separated by commas.
S) The system must now support names of videos and renters that include blanks. It must also support blanks in the address and phone numbers ofrenters. (Use getline to input these values.)
T) The system must support a LOAD and SAVE command that will allow the entire state of the VideoStore to be saved on the hard drive.

Answer A thru J:

//Inventory Class:
#pragma once
#include "VideoItem.h"
using namespace std;

enum SortStatus {unsorted,sortedByName,sortedByCode};

class Inventory
void addNewItem(const VideoItem &vi);
//void ADD_RENTER(const Renter &ri);
unsigned int size() { return vectorOfVideoItem.size();}
//unsigned int code() { return vectorOfVideoItem.code();}
VideoItem getItem(int i);
VideoItem &getItemByCode(int c);
void sortByCode();
void sortByName();
void clear(){sortStatus=unsorted;vectorOfVideoItem.clear();}
SortStatus getSortStatus(){return sortStatus;}
void setSortStatus(SortStatus ss){sortStatus=ss;}
bool isUsedCode(int c);
VideoItem &Inventory::getItemByCodeInRange(int c,int startIndex, int endIndex);
SortStatus sortStatus;
vector vectorOfVideoItem;

#include "Inventory.h"

void Inventory::addNewItem(const VideoItem &vi)

VideoItem Inventory::getItem(int i)
return vectorOfVideoItem[i];

bool Inventory::isUsedCode(int c)
VideoItem &refGi = getItemByCode(c);
return false;
return true;

VideoItem &Inventory::getItemByCode(int c)
return getItemByCodeInRange(c,0,vectorOfVideoItem.size()-1);

VideoItem &Inventory::getItemByCodeInRange(int c,int startIndex, int endIndex)
int middle=(startIndex+endIndex)/2;
VideoItem * pNullItem = new VideoItem;
return *pNullItem;
return vectorOfVideoItem[middle];
else if(startIndex==endIndex)
VideoItem * pNullItem = new VideoItem;
return *pNullItem;
else if(startIndex==middle)
return getItemByCodeInRange(c,endIndex,endIndex);
else if(c

Seen 1 years ago James Charlie 1 answers

Showing 0-1 pages of 5,000 questions

HOC.INFO Q&A communities are different.
Here's how

Expert communities.

All your questions will be answered by experts and tutors, giving you the best answer..

The right answer. Right on top.

The correct answer is prioritized at the top to help users find the correct and fastest answer.

Share knowledge. Earn trust.

You help people in the community by giving your answer and getting everyone's admiration.