Using python, write a function calcA() that determines the area under the curve ?(?) = ?? −? over the range ?1 to ?2. The area is to be determined approximately as follows: ? = ∫ ?(?) ?? ?2 ?1 ≈ ∑ 1 2 (?(?? ) + ?(??−1 ))∆? ? ?=1 (1) Where ? is the number of intervals over the range ?1 to ?2. So if ? is equal to 10, then ∆? = (?2 − ?1)/10. This function receives the two range limits and divides it into ? intervals and generates ? + 1 values and puts them in a list. The function will then iterate over this list and implement (1), above, to calculate the area under the curve. Test your calcA() function over the range 0 to 5 w. Then calculate the area of a rectangle, which is equal to 5.
In: Computer Science
Write two Java programs ( Iterative and Recursive programs )
that solves Tower of Hanoi problem?use 4 disks and 3 bars.
Students must send the code and outputs
In: Computer Science
In relation to the cellular telephone system , explain how a mobile call is established , maintained and terminated in a cellular system
In: Computer Science
In relation to satellite communication, Can the same frequency be used for uplink and downlink communication? Justify answer. Why parabolic antennas are used for satellite comunication? What is the minimum numbers of satellite that we need in the orbit to cover transmission to and reception from all over the earth
In: Computer Science
Q.We design classes to create objects in java. Write step wise procedure for
(a).How these objects created in memory?
(b). Which area of memory is used for creation of the objects?
(c). What is difference between stack and heap memory in java?
In: Computer Science
IN PYTHON :
Write one program that will compute both the Least Common Multiple, and the Greatest Common Factor of two numbers inputted by a user.
The program will display all factors and multiples of the two numbers.
When displaying the multiples of the numbers, only display up to the first input times the second input. \
Use functions to computer the answers.
Loop the program so that the user can enter two new numbers after each try.
In: Computer Science
Consider the following schema:
product (pname, price, category, manufacturer)
Purchase (buyer, seller, store, product)
Company (cname, stock price, country)
Person(per-name, phone number, city)
Write a suitable SQl for the following:
Ex #1: Find people who bought telephony products.
Ex #2: Find names of people who bought American products
Ex #3: Find names of people who bought American products and they live in Seattle.
Ex #4: Find people who have both bought and sold something.
Ex #5: Find people who bought stuff from Joe or bought products from a company whose stock prices is more than $50.
In: Computer Science
Code using JAVA:
must include "Main Method" for IDE testing!
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x),
left(left), right(right) {}
* };
*/
class Solution {
public:
vector<int> inorderTraversal(TreeNode* root) {
}
};
Given the root of a binary tree, return the inorder traversal of its nodes' values.
Example 1:
Input: root = [1,null,2,3] Output: [1,3,2]
Example 2:
Input: root = [] Output: []
Example 3:
Input: root = [1] Output: [1]
Example 4:
Input: root = [1,2] Output: [2,1]
Example 5:
Input: root = [1,null,2] Output: [1,2]
Constraints:
In: Computer Science
This program is in C++
Please kindly make sure that the output exactly matches the test case so I can vote a thumbs up. If it doesn't the program is wrong.
Test Cases and the given code are given after the prompt
Prompt:
Modify the given code to:
1.. Store the data in Binary file and access it in Random Access mode.
2.Replace Class with Structure for Employee and Department.
3. Inside each structure, replace all string variables with array of characters. please read the chapter 12(More about characters and strings). Though we do not have homework on this, the knowledge from this chapter will help you do the final exam project.
4. Make Employee and Department editable. That means, the user should be able to edit a given Employee and Department. Youc an allow the user to edit Employee name, age etc and assign him/her to different department. Similarly department name and department head can be changed. However, do not allow the uesr to Employee ID in Employee file and Department ID in department file.
5. Please note that the data will no longer be stored in the array as it was in the given code. Instead, it should be written to the file as soon as you collect the data from the user. If you are editing a record, read it from the file,collect new data from the user, store the record back to the file in the same place it was found inside the file. That means, the menu will not have options to save data to file or read data from file. Also, this should provide the ability for user to create unlimited number of employees and departments unlike in given code where you allowed only limited number of departments and employees.
Test Cases:
////////////////////////////////////
TEST CASE1: Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 1 Enter the NEW Department Data: Dept ID: 1 Dept Name: Sales Head of Dept Name: Anna Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Enter the NEW Employee Data: Employee ID: 1 Employee Name: John Employee Salary: $45000 Employee Age: 23 Department ID: 1 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 5 Salary Report By Department Dept : Sales Total Salary : $45000 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Enter the NEW Employee Data: Employee ID: 2 Employee Name: Susan Employee Salary: $50000 Employee Age: 30 Department ID: 1 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 5 Salary Report By Department Dept : Sales Total Salary : $95000 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 1 Enter the NEW Department Data: Dept ID: 2 Dept Name: Marketing Head of Dept Name: Marcus Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Enter the NEW Employee Data: Employee ID: 3 Employee Name: Adam Employee Salary: $60000 Employee Age: 30 Department ID: 2 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 5 Salary Report By Department Dept : Sales Total Salary : $95000 Dept : Marketing Total Salary : $60000 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 3 Which record to EDIT: Please choose one of the following... 1 to 2 : 2 Display Department Details: Dept ID : 2 Dept Name : Marketing Dept Head : Marcus EDIT the Department Data: Dept Name: Global Marketing Head of Dept Name: Butler Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 5 Salary Report By Department Dept : Sales Total Salary : $95000 Dept : Global Marketing Total Salary : $60000 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 4 Which record to EDIT: Please choose one of the following... 1 to 3 : 3 Display Employee Details: ID : 3 Name : Adam Salary : $60000 Age : 30 Dept : 2 Edit the Employee Data: Employee Name: Adam Employee Salary: $75000 Employee Age: 31 Department ID: 1 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 5 Salary Report By Department Dept : Sales Total Salary : $170000 Dept : Global Marketing Total Salary : $0 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 9 Please enter a valid choice (1 - 6): 6 Thank you, goodbye. TEST CASE2: Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 1 Enter the NEW Department Data: Dept ID: 1 Dept Name: HumanResources Head of Dept Name: Maria Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 1 Enter the NEW Department Data: Dept ID: 1 Please enter a unique Deptartment ID: 2 Dept Name: Marketing Head of Dept Name: Samy Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Enter the NEW Employee Data: Employee ID: 1 Employee Name: John Employee Salary: $45000 Employee Age: 35 Department ID: 9 Please enter an existing Deptartment ID: 1 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 2 Enter the NEW Employee Data: Employee ID: 1 Please enter a unique Employee ID: 2 Employee Name: Susan Employee Salary: $70000 Employee Age: 25 Department ID: 2 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 5 Salary Report By Department Dept : HumanResources Total Salary : $45000 Dept : Marketing Total Salary : $70000 Human Resources Menu 1. Create Department 2. Create Employee 3. Edit Department 4. Edit Employee 5. Display Salary Report 6. -- Quit -- Please make a selection : 9 Please enter a valid choice (1 - 6): 6 Thank you, goodbye.
/////////////////////////////////////
The Given Code:
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
using namespace std;
class Depts
{ private:
int DeptID;
string DeptName;
string DeptHName;
public:
Depts() {}
Depts(int inId, string name, string headName)
{ DeptID = inId;
DeptHName = headName;
DeptName = name;
}
string getDeptHname() const
{ return DeptHName;
}
int getDeptHID() const
{ return DeptID;
}
string getDeptName() const
{ return DeptName;
}
void setDeptHName(string DeptHName)
{ this->DeptHName = DeptHName;
}
void setDeptID(int DeptID)
{ this->DeptID = DeptID;
}
void setDeptname(string DeptName)
{ this->DeptName = DeptName;
}
};
class Employee
{ private:
int empID;
string empName;
double empSalary;
double empAge;
int empDeptID;
public:
Employee() {}
Employee(int id, string name, double salary, double age, int dId)
{ empID = id;
empName = name;
empSalary = salary;
empAge = age;
empDeptID = dId;
}
string getEmploeename() const
{ return empName;
}
int getEmpDeptID() const
{ return empDeptID;
}
int getEmpID() const
{ return empID;
}
double getEmpAge() const
{ return empAge;
}
double getEmpSalary() const
{ return empSalary;
}
void setEmpName(string empName)
{ this->empName = empName;
}
void setEmpDeptID(int empDeptID)
{ this->empDeptID = empDeptID;
}
void setEmpID(int empID)
{ this->empID = empID;
}
void setEmpAge(double empAge)
{ this->empAge = empAge;
}
void setEmpSalary(double empSalary)
{ this->empSalary = empSalary;
}
};
int main()
{ Employee employees[5];
Depts departments[3];
int noOfDepartment = 0;
int noOfEmployees = 0;
int choice;
while (choice != 6)
{ cout << "1. Create Department"
"\n2. Create Employee"
"\n3. Write Out Data File"
"\n4. Read In Data File"
"\n5. Display Salary Report"
"\n6. -- Quit -- \n"
"Please make a selection : ";
cin >> choice;
if (choice == 1)
{ if (noOfDepartment == 3)
{ cout << "The array is full, you can not add any more Depts." << endl;
continue;
}
int dId;
string dName;
string dHeadName;
cout << "Please Enter Department Details:" << endl;
cout << "Department ID : ";
cin >> dId;
bool validId = true;
for (int i = 0; i < noOfDepartment; i++)
{ if (departments[i].getDeptHID() == dId)
{ cout << "Value must be unique!" << endl;
validId = false;
}
}
if (!validId)
{ continue;
}
cout << "Department Name : ";
cin >> dName;
cout << "Head of Department : ";
cin >> dHeadName;
Depts d(dId, dName, dHeadName);
departments[noOfDepartment] = d;
noOfDepartment++;
}
else if (choice == 2)
{ if (noOfEmployees == 5)
{ cout << "The array is full, you can not add any more Employees." << endl;
continue;
}
int eId;
string eName;
double eSalary;
double eAge;
int eDepartmentid;
cout << "Please Enter Employee Details:" << endl;
cout << "Employee ID : ";
cin >> eId;
bool validId = true;
for (int i = 0; i < noOfEmployees; i++)
{ if (employees[i].getEmpID() == eId)
{ cout << "Value must be unique!" << endl;
validId = false;
}
}
if (!validId)
{ continue;
}
cout << "Employee Name :";
cin >> eName;
cout << "Salary: $";
cin >> eSalary;
cout << "Age : ";
cin >> eAge;
cout << "Department ID : ";
cin >> eDepartmentid;
bool foundId = false;
while (!foundId)
{ for (int i = 0; i < noOfDepartment; i++)
{ if (departments[i].getDeptHID() == eDepartmentid)
{ foundId = true;
break;
}
}
if (!foundId)
{ cout << "Please enter a valid department ID: ";
cin >> eDepartmentid;
}
}
Employee e(eId, eName, eSalary, eAge, eDepartmentid);
employees[noOfEmployees] = e;
noOfEmployees++;
}
else if (choice == 3)
{ ofstream myfile1("departments.txt");
ofstream myfile2("employees.txt");
for (int i = 0; i < noOfDepartment; i++)
{ myfile1 << departments[i].getDeptHID() << " " << departments[i].getDeptName() << " " << departments[i].getDeptHname() << endl;
}
for (int i = 0; i < noOfEmployees; i++)
{ myfile2 << employees[i].getEmpID() << " " << employees[i].getEmploeename() << " " << employees[i].getEmpSalary() << " " << employees[i].getEmpAge() << " " << employees[i].getEmpDeptID() << endl;
}
myfile1.close();
myfile2.close();
}
else if (choice == 4)
{ ifstream infile;
string line;
int dId;
string dName;
string dHeadName;
noOfDepartment = 0;
infile.open("departments.txt");
ifstream infile2;
int eId;
string eName;
double eSalary;
double eAge;
int eDepartmentid;
noOfEmployees = 0;
infile2.open("employees.txt");
}
else if (choice == 5)
{ string name = "";
double salary = 0;
cout<<"\n";
cout<<"Salary Report By Department\n";
for (int i = 0; i < noOfDepartment; i++)
{ salary = 0;
name = departments[i].getDeptName();
for (int j = 0; j < noOfEmployees; j++)
{ if (departments[i].getDeptHID() == employees[j].getEmpDeptID())
{ salary += employees[j].getEmpSalary();
}
}
cout << "\nDept : " << name << endl;
cout << "Total Salary : $" << salary <<endl;
}
}
else {
cout<<"Thank you, goodbye.";
return 0;
}
}
}
Thank you so much, I will leave a positive rate
In: Computer Science
Code using JAVA:
must include "Main Method" for IDE testing!
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x),
left(left), right(right) {}
* };
*/
class Solution {
public:
vector<int> preorderTraversal(TreeNode* root) {
}
};
Given the root of a binary tree, return the preorder traversal of its nodes' values.
Example 1:
Input: root = [1,null,2,3] Output: [1,2,3]
Example 2:
Input: root = [] Output: []
Example 3:
Input: root = [1] Output: [1]
Example 4:
Input: root = [1,2] Output: [1,2]
Example 5:
Input: root = [1,null,2] Output: [1,2]
Constraints:
In: Computer Science
This is the last discussion.
1) Where do you see technology leading us in terms of the future?
2) Identify a device (anything that has a CPU) that we use every day that is not protected and subject to being hacked?
3) What do you recommend to protect the device?
Please answer this question ASAP. I need it very badly.
In: Computer Science
Jenny had discovered some new friends on the Internet—friends who shared her interest in programming. One of these new friends sent her a link to a new warez (illegally copied software) site.
She downloaded a kit called Blendo from the warez site. Blendo is a tool that helps novice hackers create attack programs that combine a mass e-mailer with a worm, a macro virus, and a network scanner. She clicked her way through the configuration options, clicked a button labeled “custom scripts,” and pasted in a script that one of her new friends had e-mailed to her. This script was built to exploit a brand-new vulnerability (announced only a few hours before).
Although she didn’t know it, the anonymous high-schooler had created new malware that was soon to bring large segments of the Internet to a standstill.
She exported the attack script, attached it to an e-mail, and sent it to an anonymous remailer service to be forwarded to as many e-mail accounts as possible. She had naively set up a mailback option to an anonymous e-mail account so she could track the progress of her creation. Thirty minutes later, she checked that anonymous e-mail account and saw that she had more than 800,000 new messages; the only reason there were not even more messages was that her mailbox was full.
Required:
Evaluate the ethical issues as described in the scenario.
(1000 to 1200 words)
In: Computer Science
Code using JAVA:
must include "Main Method" for IDE testing!
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x),
left(left), right(right) {}
* };
*/
class Solution {
public:
TreeNode* sortedArrayToBST(vector<int>& nums) {
}
};
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1.
Example:
Given the sorted array: [-10,-3,0,5,9], One possible answer is: [0,-3,9,-10,null,5], which represents the following height balanced BST: 0 / \ -3 9 / / -10 5
In: Computer Science
The title of the course is OS. All answers should be based on that. Please do not copy and paste answers on chegg or on google for me. All answers should be based on your understanding on the course. Please try as much to answer the questions based on what is asked and not setting your own questions and answering them. Let it be if you want copy and paste answers.
**********************************************************************************************************************************************************************************************************************
(2)
(a). Designers are constantly undertaking research into
possible improvement that can make to various types
of memory that computers use. Often times, the
designers grapple with issues in their design of
computer memories.
(i). Critically compare and contrast cache memory
and magnetic disk storage in a computer system
that you frequently use. You may draw a
suitable diagram and/or a table of comparisons to illustrate your
answer, if you desire.
(ii).Discuss three possible issues that cache memory
designers, in your opinion, must address in their
bid to come out with effective and efficient
cache memory to satisfy the demands of
computer users; and explain how they can solve
each of the issues you have discussed.
(b).A business student has approached you for assistance
in doing an ICT assignment that he has been
struggling with, regarding modes of execution of
instructions in a computer system.
(i). Clearly explain, in your own words, the
difference between User mode and Kernel
mode of execution of instructions in a
computer system; draw diagram to illustrate
your answer.
(ii). Describe the circumstances for which System
Calls may be invoked; and explain how the
operating system responds to such invocation.
In: Computer Science
You are the data design specialist on the data warehouse project team for a retail company. Design a STAR schema to track the sales units and sales dollars with three-dimension tables. Explain how you will decide to select and build four two-way aggregates
In: Computer Science