I am coding in MySQL and two of my tables are populating find but the other two "Employee" and "Assignment" won't. I keep getting an error code saying I can't alter a child table and I can't figure out what to fix. Here is my code:
CREATE TABLE DEPARTMENT (
DepartmentName Char(35) NOT NULL,
BudgetCode Char(30) NOT NULL,
OfficeNumber Char(15) Not Null,
DepartmentPhone Char(12) NOT NULL,
CONSTRAINT DEPARTMENT_PK primary key(DepartmentName)
);
CREATE TABLE EMPLOYEE(
EmployeeNumber Int NOT NULL AUTO_INCREMENT,
FirstName Char(25) NOT NULL,
LastName Char(25) NOT NULL,
Department Char(35) NOT NULL DEFAULT 'Human Resources',
Position Char(35) NULL,
Supervisor Int NULL,
OfficePhone Char(12) NULL,
EmailAddress VarChar(100) NOT NULL UNIQUE,
CONSTRAINT EMPLOYEE_PK PRIMARY KEY(EmployeeNumber),
CONSTRAINT EMP_DEPART_FK FOREIGN KEY(Department)
REFERENCES DEPARTMENT(DepartmentName)
ON UPDATE CASCADE,
CONSTRAINT EMP_SUPER_FK FOREIGN KEY(Supervisor)
REFERENCES EMPLOYEE(EmployeeNumber)
);
ALTER TABLE EMPLOYEE AUTO_INCREMENT=1;
CREATE TABLE PROJECT(
ProjectID Int NOT NULL AUTO_INCREMENT,
ProjectName Char(50) NOT NULL,
Department Char(35) NOT NULL,
MaxHours Numeric(8,2) NOT NULL DEFAULT 100,
StartDate Date NULL,
EndDate Date NULL,
CONSTRAINT PROJECT_PK PRIMARY KEY(ProjectID),
CONSTRAINT PROJ_DEPART_FK FOREIGN KEY(Department)
REFERENCES DEPARTMENT(DepartmentName)
ON UPDATE CASCADE
);
ALTER TABLE PROJECT AUTO_INCREMENT=1000;
CREATE TABLE ASSIGNMENT (
ProjectID Int NOT NULL,
EmployeeNumber Int NOT NULL,
HoursWorked Numeric(6,2) NULL,
CONSTRAINT ASSIGNMENT_PK PRIMARY KEY(ProjectID, EmployeeNumber),
CONSTRAINT ASSIGN_PROJ_FK FOREIGN KEY(ProjectID)
REFERENCES PROJECT(ProjectID)
ON UPDATE NO ACTION
ON DELETE CASCADE,
CONSTRAINT ASSIGN_EMP_FK FOREIGN KEY(EmployeeNumber)
REFERENCES EMPLOYEE(EmployeeNumber)
ON UPDATE NO ACTION
ON DELETE NO ACTION
);
INSERT Department(DepartmentName, BudgetCode, OfficeNumber, DepartmentPhone)
VALUES('Administration', 'BC-100-10', 'BLDG01-201', '360-285-8100'),
('LEGAL', 'BC-200-10', 'BLDG01-220', '360-285-8200'),
('Human Resources', 'BC-300-10', 'BLDG01-230', '360-285-8300'),
('Finance', 'BC-400-10', 'BLDG01-110', '360-285-8400'),
('Accounting', 'BC-500-10', 'BLDG01-120', '360-285-8405'),
('Sales and Marketing','BC-600-10', 'BLDG01-250', '360-285-8500'),
('InfoSysems', 'BC-700-10', 'BLDG02-210', '360-285-8600'),
('Research and Development', 'BC-800-10', 'BLDG02-250', '360-285-8700'),
('Production', 'BC-900-10', 'BLDG02-110', '360-285-8800')
INSERT Employee(EmployeeNumber, FirstName, LastName, Department, Position, Supervisor, OfficePhone, EmailAddress)
VALUES('1', 'Mary', 'Jacobs', 'Administration', 'CEO', NULL, '360-285-8110', '[email protected]'),
('2', 'Rosalie', 'Jackson', 'Administration', 'AdminAsst', '1', '360-825-8120', '[email protected]'),
('3', 'Richard', 'Bandalone', 'Legal', 'Attorney', '1', '360-285-8210', '[email protected]'),
('4', 'George', 'Smith', 'Human Resources', 'HR3', '1', '360-285-8310', '[email protected]'),
('5','Alan', 'Adams', 'Human Resources', 'HR1', '4', '360-285-8320', '[email protected]'),
('6', 'Ken', 'Evans', 'Finance', 'CFO', '1', '360-285-8410', '[email protected]'),
('7', 'Mary', 'Abernathy', 'Finance', 'FA3', '6', '360-285-8420', '[email protected]'),
('8', 'Tom', 'Caruthers', 'Accounting', 'FA2', '6', '360-285-8430', '[email protected]'),
('9', 'Heather', 'Jones', 'Accounting', 'FA2', '6', '360-825-8440', '[email protected]'),
('10', 'Ken', 'Numoto', 'Sales and Marketing', 'SM3', '1', '360-285-8510', '[email protected]'),
('11', 'Linda', 'Granger', 'Sales and Marketing', 'SM3', '10', '360-285-8520', '[email protected]'),
('12', 'James', 'Nestor', 'InfoSystems', 'CIO', '1', '360-285-8610', '[email protected]'),
('13', 'Rick', 'Brown', 'InfoSystems', 'IS2', '12', NULL, '[email protected]'),
('14', 'Mike', 'Nguyen', 'Research and Development', 'CTO', '1', '360-285-8710', '[email protected]'),
('15', 'Jason', 'Sleeman', 'Research and Development', 'RD3', '14', '360-285-8720', '[email protected]'),
('16', 'Mary', 'Smith', 'Production', 'OPS3', '1', '360-825-8810', '[email protected]'),
('17', 'Tom', 'Jackson', 'Production', 'OPS2', '16', '360-825-8820', '[email protected]'),
('18', 'George', 'Jones', 'Production', 'CPS2', '17', '360-825-8830', '[email protected]'),
('19', 'Julia', 'Hayakawa', 'Production', 'CPS1', '17', NULL, '[email protected]'),
('20', 'Sam', 'Stewart', 'Production', 'OPS1', '17', NULL, '[email protected]')
INSERT Project(ProjectID, ProjectName, Department, MAxHours, StartDate, EndDate)
VALUES ('1000', '2017 Q3 Production Plan', 'Production', '100.00', '05/10/17', '2017-06-15'),
('1100', '2017 Q3 Marketing Plan', 'Sales and Marketing', '135.00', '05/10/17', '2017-06-15'),
('1200', '2017 Q3 Portfolio Analysis', 'Finance', '120.00', '07/05/17', '2017-07-25'),
('1300', '2017 Q3 Tax Preparation', 'Accounting', '145.00', '08/10/17', '2017-10-15'),
('1400', '2017 Q4 Production Plan', 'Production', '100.00', '08/10/17', '2017-09-15'),
('1500', '2017 Q4 Marketing Plan', 'Sales and Marketing', '135.00', '08/10/17', '2017-09-15'),
('1600', '2017 Q4 Portfolio Analysis', 'Finance', '140.00', '10/05/17', NULL)
INSERT Assignment(ProjectID, EmployeeNumber, HoursWorked)
VALUES('1000', '1', '30.00'),
('1000', '6', '50.00'),
('1000', '10', '50.00'),
('1000', '16', '75.00'),
('1000', '17', '75.00'),
('1100', '1', '30.00'),
('1100', '6', '75.00'),
('1100', '10', '55.00'),
('1100', '11', '55.00'),
('1200', '3', '20.00'),
('1200', '6', '40.00'),
('1200', '7', '45.00'),
('1200', '8', '45.00'),
('1300', '3', '25.00'),
('1300', '6', '40.00'),
('1300', '8', '50.00'),
('1300', '9', '50.00'),
('1400', '1', '30.00'),
('1400', '6', '50.00'),
('1400', '10', '50.00')
In: Computer Science
Write a program that implements the pseudocode ("informal
high-level description of the operating principle of a computer
program or other algorithm") below:
1. Ask the user for the size of their apartment in square meters
(size)
2. Convert the size to square feet using the formula: convertedSize
= size * 10.764
3. Print out the converted size.
Have meaningful prompts and meaningful explanation of any numbers
printed.
In: Computer Science
Hi I am getting error in implement some test case using Java. I am adding my code and relevant files here, and the failed test. Please let me know where my problem is occuring and fix my code. Thanks! I will upvote.
Implement a class to perform windowing of a Hounsfield value
Implement the class described by this API. A partial implementation is provided for you in the eclipse project; however, unlike the previous class, very little work has been done for you. You must carefully study the API of the class to determine the precise signatures of the constructors and methods that you need to implement. Furthermore, you need to thoroughly understand the concept of windowing to determine what fields are required in your class.
Remember to run the JUnit tester each time you complete a constructor or method, and to carefully study the result of the tests to help you through the development process.
API doc: https://drive.google.com/open?id=1GKm_m74PwFBZIC__JmnWnGi6cFzmGuul
/**
* A class that represents a windowed view of Hounsfield units. A
Hounsfield
* window is defined by two values: (1) the window level, and (2)
the window
* width. The window level is the Hounsfield unit value that the
window is
* centered on. The window width is the range of Hounsfield unit
values that the
* window is focused on.
*
*
* A window has a lower and upper bound. The lower bound is defined
as the
* window level minus half the window width:
*
*
* lo = level - (width / 2)
*
*
* The upper bound is defined as the window level plus half the
window width:
*
*
* hi = level + (width / 2)
*
*
* Hounsfield units are mapped by the window to a real number in the
range of
* {@code 0} to {@code 1}. A Hounsfield unit with a value less than
lo is mapped
* to the value {@code 0}. A Hounsfield unit with a value greater
than hi is
* mapped to the value {@code 1}. A Hounsfield unit with a value v
between lo
* and hi is mapped to the value:
*
*
* (v - lo) / width
*
*
*/
public class HounsfieldWindow {
private int level;
private int width;
HounsfieldWindow(int level, int width) {
setLevel(level);
this.width = width;
}
public HounsfieldWindow() {
this(0, 400);
}
public int getLevel() {
return level;
}
public int setLevel(int level) {
if (level < Hounsfield.MIN_VALUE
|| level > Hounsfield.MAX_VALUE) {
throw new
IllegalArgumentException();
}
int data = this.level;
this.level = level;
return data;
}
public int getWidth() {
return width;
}
public int setWidth(int width) {
if(width < 1) {
throw new
IllegalArgumentException();
}
int data = this.width;
this.width = width;
return data;
}
public double getLowerBound() {
return level - (width / 2);
}
public double getUpperBound() {
return level + (width / 2);
}
public double map(Hounsfield h) {
// TODO Auto-generated method
stub
int hounsfieldUnitVal =
h.get();
System.out.println("got " + hounsfieldUnitVal);
if(hounsfieldUnitVal < getLowerBound()) {
return 0;
}
if(hounsfieldUnitVal > getUpperBound()) {
return 1;
}
return (hounsfieldUnitVal - getLowerBound()) /
(double)width;
}
}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tests that fails:
@Test
public void test04_ctorThrowsOnBadWidth() {
final int[] BAD_WIDTHS = {-10000,
-10, 0};
for (int width : BAD_WIDTHS)
{
try {
new HounsfieldWindow(0, width);
fail(String.format("new HounsfieldWindow(0, %s)
should throw an exception", width));
}
catch
(IllegalArgumentException x) {
// ok
}
}
}
@Test
public void test10_map() {
assumeTrue("test requires a correct
implementation of HounsfieldWindow(int, int)", IS_CTOR_OK);
// uses windows of width 1
// easy to test because map should
always return 0.5 for
// Hounsfield values inside the
window
final int width = 1;
for (int level =
Hounsfield.MIN_VALUE; level <= Hounsfield.MAX_VALUE; level++)
{
// make a window
to call map on
HounsfieldWindow
w = new HounsfieldWindow(level, width);
// the actual
value returned by map
double got =
w.map(new Hounsfield(level));
// make an
error message in case the test fails
String error =
String.format(
"map(%s) failed to return the
correct value for a window with level %s, width %s", level,
level,
width);
// assert
that 0.5 equals got
assertEquals(error, 0.5, got, 1e-9);
}
}
@Test
public void test11_map() {
assumeTrue("test requires a correct
implementation of HounsfieldWindow(int, int)", IS_CTOR_OK);
// tests Hounsfield units in
windows of various widths and levels
final int[] WIDTH = {2, 3, 4, 5,
10, 25, 50, 75, 100, 255};
final int[] LEVEL = {-800, -1, 1,
750};
for (int level : LEVEL) {
for (int width :
WIDTH) {
// make a window to call map on
HounsfieldWindow w = new HounsfieldWindow(level,
width);
// expected values map should return
double[] EXP =
HounsfieldWindowTest.mapValues(width);
for (int i = 0; i < EXP.length; i++) {
// Hounsfield unit to
map
Hounsfield h = new
Hounsfield(level - width / 2 + i);
// the expected return value
of map(h)
double exp = EXP[i];
// the actual value returned
by map(h)
double got = w.map(h);
// make an error message in
case the test fails
String error =
String.format(
"map(%s) failed to return the correct value for
a window with level %s, width %s", h.get(), level,
width);
// assert that exp equals
got
assertEquals(error, exp, got,
1e-9);
}
}
}
}
Relevant files(Hounsfield.java and Hounsfieldtest.java): https://drive.google.com/open?id=1HRUH5bika5xeLO7G_kP2LeMxNeXejRgl
In: Computer Science
Write a C program to calculate the number of fence panels needed over a given distance. The fence must be created using two difference size panels which have a 2 foot length difference between them (ie. panels could be 2’ and 4’ or 3’ and 5’ or 5’and 7’). Your program should request the total length of the fence and the smaller panel's size. Your program will then calculate the length of the larger panel and output the number of each size panel necessary for the given length of fence. If there is a length of fence that is different from the two panel sizes, you should consider that to be a special size panel that is necessary to complete the length of fence. Output the length of that special panel. The examples below show different inputs and the expected outputs.
Here is an example of running your program with different
inputs.
NOTE: Bold text represents input that someone will type
into your program.
Measurement of the fencing needed (feet): 50 Enter the size of smaller panel in feet: 3 The larger panel will be 5 feet. Happy Building!! The fence will need 6 qty 3 foot panel(s) and 6 qty 5 foot panel(s). Plus a special order 2 foot panel. ----------------------------------- Measurement of the fencing needed (feet): 50 Enter the size of smaller panel in feet: 4 The larger panel will be 6 feet. Happy Building!! The fence will need 5 qty 4 foot panel(s) and 5 qty 6 foot panel(s). ----------------------------------- Measurement of the fencing needed (feet): 2 Enter the size of smaller panel in feet: 1 The larger panel will be 3 feet. Happy Building!! The fence will need 2 qty 1 foot panel(s) and 0 qty 3 foot panel(s). ----------------------------------- Measurement of the fencing needed (feet): 52 Enter the size of smaller panel in feet: 3 The larger panel will be 5 feet. Happy Building!! The fence will need 7 qty 3 foot panel(s) and 6 qty 5 foot panel(s). Plus a special order 2 foot panel. ----------------------------------- Measurement of the fencing needed (feet): 0 Please enter an integer > 0: 54 Enter the size of smaller panel in feet: -34 Please enter an integer > 0: 4 The larger panel will be 6 feet. Happy Building!! The fence will need 6 qty 4 foot panel(s) and 5 qty 6 foot panel(s). |
In: Computer Science
1.)recursive merge sort on a list.(Python)
2.)recursive bubble sort using a list without enumerate() function.(python)
Show Base case, and recursive case.
In: Computer Science
the following has differing roles within a large IT
department in the development of a new computer system. define
these roles and responsibilities;
1. project manager
2. technical manager
3. database administrator
In: Computer Science
In: Computer Science
Simple Java class.
Create a class Sportscar that inherits from the Car class includes the following:
a variable roof that holds type of roof (ex: convertible, hard-top,softtop)
a variable doors that holds the car's number of doors(ex: 2,4)
implement the changespeed method to add 20 to the speed each time its called
add exception handling to the changespeed method to keep soeed under 65
implement the sound method to print "brooom" to the screen.
create one constructor that accepts the car's roof,doors, year, and make as arguments and assigns the values appropriately. do not create any other constructors.
the interface methods should print messages using system.out.println()
car class:
abstract clas Car implements Vehicle(
private int year;
private int speed;
private string make;
private static int count=0;
public car(int year, string amake){
year = aYaer;
make = aMake;
speed =0;
count++;}
public void sound();
public static int getcount90{
return count;}
}
In: Computer Science
In: Computer Science
What is the exact output of the following pseudocode segment?
METHOD MAIN
CALL myMethod (0,2)
CALL myMethod (3,5)
CALL myMethod (6,7)
END MAIN
|
Answer: |
METHOD myMethod(A,B)
BEGIN
WHILE (A < B)
PRINT(A + "
")
A ← A + 1
ENDWHILE
PRINTLINE();
END MyMethod
In: Computer Science
Why the recursion in Pascal's Triangle is also the recursion for counting sub-sets.
In: Computer Science
I need this in PSEUDOCODE:
Write a method, called PrintNumbers, that prints out the following sequence of numbers. The method must use a for-loop to print the outputs. HINT: “To get started: what’s the pattern from number X to (X+1)? Does it apply to the next pair of numbers?” 8 12 18 26 36 48 62
In: Computer Science
In python please
6.12 Mortgage Example
A mortgage company is interested in automating their decision-making process.
As part of this automation, they are looking for a software that takes a set of information from each customer and identify
1) if a customer is eligible to apply for a mortgage
2) if a customer is qualified to get the mortgage of the requested amount,
eligibility criteria:
1. the applicant should be 19 or over 19 years old
2. the applicant should be the resident of that country (in the beginning assume that the applicant needs to be a resident of U.S.)
qualification criteria
1. the applicant should be eligible
2. the difference between the applicant's monthly income and applicant's monthly expenses should be greater than the mortgage monthly payments
Considering the code in the template, complete the code so that it prints; 1) if the user is eligible 2) the amount of monthly mortgage payment for the requested amount of mortgage with a specific interest rate taken from input and specific amount of time (in years) to pay off the mortgage, and 3) if the used is qualified
Hint: use this formula to calculate the monthly mortgage payment: (RequestedMortgageAmount + (RequestedMortgageAmount * overallinterestrate)) / (years * 12)
please consider 15%, 20% and 24% overall interest rate for pay offs in 10, 15, and 30 years, respectively. Round down the monthly mortgage payment using int() function.
Fix the mortgagemonthlypayment function and then call it in the main program with appropriate inputs.
Given code:
# we define four functions; eligible(),
difference_btw_incomeAndexpense(), mortgae_monthly_payment() and
qualify()
# reminder: each function is like a template and it does not run
unless we call it with appropriate set of input values
# This function takes applicant's age and country of residence
and return a boolean variable;if True meaning that the applicant is
eligible
def eligible(age, country_of_residence):
elig = False
if (age >= 19) and (country_of_residence == 'USA'):
elig = True
return elig
# This function takes the family income value and all expenses and
calculate the difference btw them and return the difference
def difference_btw_incomeAndexpense(family_income, loan_payments,
educations_payment, groceryAndfood, others):
diff = family_income - (loan_payments + educations_payment +
groceryAndfood + others)
return diff
# This function takes the user requested amount of mortgage and
applies an interest rate to it and calculates the monthly payment
amount
# This function applies 20% overall interest rate over 15
years
# you can make changes to this function and make it closer to what
happens in reality. How ????????????????????
#def mortgage_monthly_payment(RequestedMortgageAmount):
# m_p = (RequestedMortgageAmount + (RequestedMortgageAmount * 0.2))
/ (15 * 12)
# return m_p
def mortgage_monthly_payment(RequestedMortgageAmount,
years):
#### FIX ME
# This function takes the output of the last two function and
the amount of mortgage monthly payments and return if the applicant
is qualified or not
def qualify(elig, diff, mortgage_monthly_payment):
qual = False
if (elig == True) and (diff > mortgage_monthly_payment):
qual = True
return qual
# the main program
# sometimes, we write a function and we want to use that in
other Python scripts as a module.
# In this example, we want to use all three functions in the
current program (script)
# the following if statement is used to tell Python that we want to
use the above-defined functions in the current Python script.
if __name__ == "__main__":
print('please enter your age:')
age = int(input())
print('Please enter the country of residence. If you are a resident
of the United States enter USA:')
country = input()
family_income = int(input('Please enter your family total monthly
income:'))
loan_payment = int(input('Please enter your family amount of
monthly loan payment:'))
edu = int(input('Please enter an estimate of your family amount of
monthly education payment:'))
groceryAndfood = int(input('Please enter your family amount of
monthly grocery and food expenses:'))
others = int(input('Please enter the amount of other expenses not
listed above:'))
requested_mortgage_amount = int(input('Please enter the amount of
the mortgage you arerequesting:'))
####### COOMPLETE ME
# we call eligible() function
# we keep the result of eligible() function in variable E and then
test E using a conditional statement to print eligible or not
eligible
E = eligible(age, country)
if E == True:
print('you are eligible')
else:
print('you are not eligible')
# calling difference_btw_incomeAndexpense() function and keeping
its outcome in Difference variable so that we can use it later on
when we call qualify() function
Difference = difference_btw_incomeAndexpense(family_income,
loan_payment, edu, groceryAndfood, others)
# calling mortgage_monthly_paymenr() function and keeping its
outcome in Mortgage_m_p variable to be used in qualify() function
later on
# fixme
# calling qualify() function using the outputs of eligible(), E,
the output of diff(), Difference, and the output of
mortgage_monthly_payment(), Mortgae_m_p
Qual = qualify(E, Difference, Mortgage_m_p)
# since Qual is either True or Fasle, we want to use it to print
a stetement to tell the user if they are qualified or not
if Qual == True:
print('you are qualified')
else:
print('you are not qualified')
In: Computer Science
You were hired as the manager for network services at a medium-sized firm. This firm has 3 offices in 3 American cities. Recently, the firm upgraded its network environment to an infrastructure that supports converged solutions. The infrastructure now delivers voice, data, video, and wireless solutions. Upon assuming the role of network manager, you started reviewing the documentation and policies in place for the environment to ensure that everything is in place for the upcoming audit. You notice that a formal network security policy is nonexistent. You need one. The current network environment and services are as follows:
Considering the network environment, services, and solutions that are supported, develop a network security policy of 3–4 pages for the environment, including the following:
In: Computer Science
Note: There is no database to test against
| WorkerId | Number(4) | Not Null [PK] |
| WorkerName | Varchar2(20) | |
| CreatedDate | DATE | |
| CreatedBy | Varchar2(20) |
Create a stored procedure (SP) called Add_Worker that will add an employee to a factory. This SP has two parameters:
a) A parameter (WorkerId) that the SP can read or write to. When the procedure is called it will contain the PK value that should be used to add the row.
b) A parameter (WorkerName) that the SP can read only, it contains the new worker's username.
c) A parameter (Result) that the SP can write to. If the new record is added successfully, the parameter will be set to the value 'Entered Successfully'. If the add fails the parameter is set to the value 'Unsuccessful'.
Declare an exception named WORKER_NOT_ADDED. Associate the number -20444 with this exception.
Execute an insert statement to add the row to the table. Use the values of the passed parameters on the insert statement. Today's date should be used for the Created_date column. Use 'abcuser' for the CreatedBy column.
If the workerID is added:
a) Set the parameter 'Result' to 'Entered Successfully'
b) Commit the changes
Next, add exception processing to the SP
a) For all exceptions, set the parameter 'Result' to 'Unsuccessful'
b) If the WORKER_NOT_ADDED exception occurs, display the message 'New WorkerId already exists on the table.'
c_ For any other error, display the error number and the message associated with that error number.
In: Computer Science