Describe some of the risks associated with the “bring your own device” movement and some of the policies companies have established to mitigate these risks.
Provide examples of how biases in data sets used to train artificial-intelligence systems resulted in poor performance of these systems across diverse populations.
In: Computer Science
We want to provide home-delivery service to our customers.
Select one:
a. Business Requirement
b. User/Stakeholder Requirement
c. Functional Requirement
d. Non-Functional Requirement
In: Computer Science
Consider the following IPv4 forwarding table, using CIDR. As in exercise 1, IP address bytes are in hexadecimal, and “:” is used as the separator as a reminder.
destination | next_hop |
---|---|
00:0:0:0/2 | A |
40:0:0:0/2 | B |
80:0:0:0/2 | C |
c0:0:0:0/2 | D |
(a). To what next_hop would each of the following be routed? 63:b1:82:15, 9e:00:15:01, de:ad:be:ef
(b). Explain why every IP address is routed somewhere, even though there is no default entry. Hint: convert the first bytes to binary
In: Computer Science
Your assignment is to write a C++ program to read a text file containing the information of the employees of a company, load them into memory and perform some basic human resources operations. This assignment will help you practice: multiple file programming, classes, public and private methods, dynamic memory allocation, constructors and destructors, singly linked list and files.
Implementation
This lab assignment gives you the opportunity to practice creating classes and using dynamic memory in one of the required classes. There are two classes to implement Employee and Company. #the Company will hold a linked list of Employees. This list of employees is modeled using linked nodes of Employee* (pointers to Employees). These employees are created dynamically when they are added to the list.
You will create the following files:
Class Descriptions
Employee
Notice there are no changes from previous Employee implementation
Access | Member | Description |
---|---|---|
Private | _id: unsigned int | ID |
Private | _name: string | Name |
Private | _salary: double | Salary |
Private | _managerId: unsigned int | Manager ID |
Public | Employee(unsigned int, const string&, double, unsigned int=0 | Creates an employee using the values given by the parameters. The last parameter represents the manager ID. If the name parameter is an empty string, the constructor should initialize the name to “***” |
Public | Employee(const Employee&) | Copy constructor for Employee |
Public | GetID(): unsigned int | Accessor for ID |
Public | GetName(): string | Accessor for name |
Public | GetSalary():double | Accessor for salary |
Public | GetManagerId(): unsigned int | Accessor for Manager ID |
Public | ToString():string | Returns a string representation of the Employee. (see after the table for the details on this method) |
Public | Raise(double):void | Gives a raise to the employee, adding the specified amount to his or her current salary. |
Public | Equals(const Employee&) | Returns true if the employee specified by the parameter has same ID as current object. |
Public | Read(istream&):bool | Reads an employee from the istream returning true/false depending on whether read was successful. |
Public | Write(ostream&):void | Writes the information about an employee, separated by spaces, to the ostream. |
Public | ~Employee() | Destructor, empty |
Company
Access | Member | Description |
---|---|---|
Private | struct Node{Employee* data; Node* next; } | Represents the node type that will become each of the links of the linked list. |
Private | _head: Node* | Head of the list, is the pointer to the first element of the list. |
Private | _size: unsigned int | The number of actual employees in the list. In the beginning, there are no employees. |
Private | Company(const Company&) | Copy constructor private to prevent copies from 'outside' the class. |
Public | Company() | Constructor for Company. Sets the _size to zero, initializes _head to nullptr. |
Public | AddEmployee(unsigned int, const string&, double, unsigned int=0): bool | Adds an employee to the list (to the correct position, the list must always be sorted). The parameters specify the information about the employee. Returns true if it was able to add it, false otherwise. |
Public | AddEmployee(const Employee&): bool | Adds the specified employee to the list(to the correct position, the list must always be sorted). Returns true if it was able to add it, false otherwise. |
Public | FindById(unsigned int): int | Uses binary search to find an employee using the ID given in the parameter. Returns -1 if the employee is not found. If it is found returns the position of that employee. |
Public | FindByName(const string&, unsigned int=0) | Uses linear search starting from the position specified by the second parameter to find the first occurrence of the given name in the Array. Returns -1 if the employee is not found. If it is found returns the position of that employee. |
Public | Read(istream&):int | Reads an istream and extracts all the employees’ data from there, and adds the employees to existing list of employees. Returns the number of employees read. |
Public | Write(ostream&):int | Writes all the available employees to the ostream. Returns the number of employees written. |
Public | IsFull():bool | Always returns false. |
Public | Get(unsigned int): Employee* | Returns a pointer to the Employee at the position specified by the parameter. If the position is invalid, it returns nullptr. The referenced object belongs to the object and should not be “deleted” by the client. |
Public | GetEmployeeCount():unsigned int | Returns the number of employees in the Company (_size) |
Public | ~Company() | Frees the memory by releasing all the dynamically created employees in the array. |
Employee::ToString(), returns a formatted string following the following format:
ID: 1 Name: Peter Salary: 250 Manager ID: 0
Widths:
Program Menu
Your program should output the following menu:
1. Load from File 2. Save to File 3. List all Employees 4. Search by Name 5. Search by ID 6. Find Employee Boss Information 7. Add new Employee 8. Check if Database is Full 9. Exit
Menu Option | Description |
---|---|
Load a Company File | Asks the user for the file name containing the employee’s information. TXT files containing sample company information are included with this Lab document. |
Save Company Data to File | Saves the current information in memory to a file. The program asks the user for the file name where the user wants to save this. |
List all Employees | Lists all the employees stored in memory. Uses company ToString method to display them. |
Search by Name | The user inputs a name, then, using the method FindFirstByName the program displays all employees with that name using ToString method. |
Search by ID | The user inputs an ID, then, using the method FindById the program displays the employee with that ID using ToString method or that it did not find that ID. |
Find Employee Boss Information | The user inputs an ID, then, using the method FindById the program displays the employee ID using GetID method or that it did not find that ID. Once the employee is found, gets the manager’s ID, and with it searches that ID and gets the manager’s rest of the information. Displays the manager information using ToString method. |
Add New Employee | Requests the user to enter the following information about the employee: ID, name, salary and manager ID. Manager ID is zero for employees without boss. Only adds employees if it fits in the array! Only adds employees with ID that is not already in the list |
Check if Database is Full | Displays a message indicating if the database is full, or not full. |
Exit | Exits the program |
In: Computer Science
Thank You
In: Computer Science
Troubleshoot the code to create a dynamic input field to take
numerical inputs and label strings to draw a pie chart.
<html>
<head>
<title>AddingRows</title>
</head>
<header>
<h1>AddingRows</h1>
</header>
<style>
table, td {
border-style:double;
border-color: black;
}
</style>
<body>
<table id="shtol">
<tr>
<td>Label 2 </td>
<td><input type="text" class = "labelIn"/></td>
<td>Percentage</td>
<td><input type="number" class = "percentIn"/></td>
</tr>
<tr>
<td>Label 1 </td>
<td><input type="text" class = "labelIn"/></td>
<td>Percentage</td>
<td><input type="number" class = "percentIn"/></td>
</tr>
</table>
<br>
<button type="button" onclick="addR()">Add Label</button>
<button type="button" onclick="drawChart()">Draw the Pie Chart</button>
<div id="chart_div"></div>
<p id = "counters" style = "display:none">2</p>
<script>
function addR() {
var counterHT = document.getElementById('counters');
var counter = counterHT.innerHTML;
counter++;
counterHT.innerHTML = counter;
var table = document.getElementById("shtol");
var row = table.insertRow(0);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var cell4 = row.insertCell(3);
cell1.innerHTML= "Label " + counter;
cell2.innerHTML = "<input type = text>";
cell2.classList.toggle("labelIn");
cell3.innerHTML = "Percentage ";
cell4.innerHTML = "<input type = text>";
cell4.classList.toggle("percentIn");
}
function drawChart(){
var data = new google.visualization.DataTable();
data.addColumn('string', 'Label');
data.addColumn('number', 'Percentage');
var x = document.getElementsByClassName("labelIn");
var y = document.getElementsByClassName("percentIn");
var i;
for(i = 0; i < x.length; i ++){
data.addRows([
[x[1].value,y[1].value]
])
}
var myTitle = document.getElementById("title").value;
// Set chart options
var options = {'title':myTitle,
'width':400,
'height':300};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</body>
</html>
In: Computer Science
Write a function that removes all even numbers from an array. The function should take the array, length of the array, and a pointer for number of odd numbers found as arguments and return a pointer to the new array. If there are no odd numbers found in the array, your code should print "No odds found." and return NULL.
Use the function header:
int *removeEvens(int *a, int length, int *oddsFound);
Example:
Input array a[ ] = {3, 4, 5, 6, 7}
*oddsFound = 3
return array = {3, 5, 7}
The size of the return array needs to be the number of odd numbers found.
Note: You can determine if a number is even by checking if a[x] % 2 == 0.
In: Computer Science
Consider the relational schemas given below and the respective sets of functional dependencies valid in the schemas. For each one of the relational schemas identify its highest normal form. Remember that the identification of a normal form requires analysis of the valid functional dependencies and the minimal keys. Provide justification of each answer. A solution with no comprehensive justification scores no marks.
(iv) When a staff is required to undertake an inspection of
properties, the staff is allocated a company car for the day. A
staff may inspect several properties on a given date, and a
property is only inspected once on a given date. These information
of the inspection are stored in the following relational
table:
PropertyInspection(PropertyNum, IDate, ITime, Comments, StaffNum,
CarRegNum)
(vi) Each student is assigned with a counselor who will act as
an advisor to the students. The student is given the counselor
email address so that the student can contact the counselor for
advice. The information on the student and counselor are stored in
the following relational table.
STUDENTCOUNSELOR (StdNum, StdName, CounselorName,
CounselorEmail)
In: Computer Science
Write a function in Python to take in a piece of sample text via a long string (you pick the string) and to output a dictionary with each word as a key and it’s frequency (the number of times it occurred in the original string) as the value. Show an example of your function in use. Be sure to strip out any punctuation.
In: Computer Science
Write a Java program to encrypt and decrypt a phrase using two similar approaches, each insecure by modern standards.
The first approach is called the Caesar Cipher, and is a simple “substitution cipher” where characters in a message are replaced by a substitute character.
The second approach, due to Giovan Battista Bellaso (b 1505, d 1581), uses a key word, where each character in the word specifies the offset for the corresponding character in the message, with the key word wrapping around as needed.
⦁ Using loops
⦁ String and character processing
⦁ ASCII codes
⦁ Data Manager class – CryptoManager.java
⦁ Implement each of the methods specified in this file.
This version as provided will print error messages in the console,
because they are just the skeletons.
⦁ Each of the methods are static, so there is no need
to create an instance of the Data Manager.
⦁ Document each of your methods with a simple
description and document the class with a simple description and
your name using in-line comments (//…). (Just a short sentence
fragment will suffice for each documentation string.)
⦁ The methods are described below.
⦁ public static boolean stringInBounds (String
plainText);
This method determines if a string is within the
allowable bounds of ASCII codes according to the LOWER_BOUND and
UPPER_BOUND characters. The parameter plainText is the string to be
encrypted. The method returns true if all characters are within the
allowable bounds, false if any character is outside.
⦁ public static String encryptCaesar(String plainText,
int key);
This method encrypts a string according to the Caesar Cipher. The
integer key specifies an offset and each character in plainText is
replaced by the character the specified distance away from it. The
parameter plainText is an uppercase string to be encrypted. The
parameter key is an integer that specifies the offset of each
character. The method returns the encrypted string.
⦁ public static String decryptCaesar(String
encryptedText, int key);
This method decrypts a string according to the Caesar Cipher. The
integer key specifies an offset and each character in encryptedText
is replaced by the character "offset" characters before it. This is
the inverse of the encryptCaesar method. The parameter
encryptedText is the encrypted string to be decrypted, and key is
the integer used to encrypt the original text. The method returns
the original plain text string.
⦁ public static String encryptBellaso(String plainText,
String bellasoStr);
This method encrypts a string according to the Bellaso Cipher. Each
character in plainText is offset according to the ASCII value of
the corresponding character in bellasoStr, which is repeated to
correspond to the length of plaintext. The method returns the
encrypted string.
⦁ public static String decryptBellaso(String
encryptedText, String bellasoStr);
This method decrypts a string according to the Bellaso Cipher. Each
character in encryptedText is replaced by the character
corresponding to the character in bellasoStr, which is repeated to
correspond to the length of plainText. This is the inverse of the
encryptBellaso method. The parameter encryptedText is the encrypted
string to be decrypted, and bellasoStr is the string used to
encrypt the original text. The method returns the original plain
text string.
⦁ Add additional methods if you wish to make your logic
easier to follow.
⦁
⦁ GUI Driver class – (provided)
⦁ A Graphical User Interface (GUI) is provided. Be sure
that the GUI will compile and run with your methods. The GUI will
not compile if your method headers in CryptoManager.java are not
exactly in the format specified. When you first run the
application, your methods will all throw exceptions, which will be
caught by the GUI and printed out in the console.
⦁ Do not modify the GUI.
⦁ The GUI takes care of capitalizing your input
strings.
⦁
⦁ JUnit Test/Test Driver
⦁ Once your methods are implemented, run the test
driver. Ensure that the driver file results in the following
output, as shown in RED (of course the output will not be in red
when you run the test driver):
⦁ "THIS TEST SHOULD SUCCEED" Is it in bounds?
true
⦁ "THIS TEST THAT SHOULD FAIL BECAUSE { IS OUTSIDE THE
RANGE" Is it in bounds? false
⦁ "This test should fail because of lowercase letters"
Is it in bounds? false
⦁ Caesar cipher of "THIS IS ANOTHER TEST" should return
"WKLV#LV#DQRWKHU#WHVW": WKLV#LV#DQRWKHU#WHVW
⦁ Bellaso cipher of "THIS IS ANOTHER TEST" should
return "WU\VR9F#N!RF88U-'HED": WU\VR9F#N!RF88U-'HED
⦁ Caesar decryption of "WKLV#LV#DQRWKHU#WHVW" should
return "THIS IS ANOTHER TEST": THIS IS ANOTHER TEST
⦁ Bellaso decryption of "WU\VR9F#N!RF88U-'HED" should
return "THIS IS ANOTHER TEST": THIS IS ANOTHER TEST
⦁ Run the JUnit test file (provided). Ensure that the
JUnit tests all succeed.
⦁ Include CryptoGFATest.java and CryptoManagerTest.java
with the rest of your submission.
The first approach is called the Caesar Cipher, and is a simple
“substitution cipher” where characters in a message are replaced by
a substitute character. The substitution is done according to an
integer key which specifies the offset of the substituting
characters. For example, the string ABC with a key of 3 would be
replaced by DEF.
If the key is greater than the range of characters we want to
consider, we “wrap around” by subtracting the range from the key
until the key is within the desired range. For example, if we have
a range from space (‘ ‘) to ‘_’ (i.e., ASCII 32 to ASCII 95), and
the key is 120, we note that 120 is outside the range. So we
subtract 95-32+1=64 from 120, giving 56, which in ASCII is the
character ‘8’. If the key is even higher, we can subtract the range
from the key over and over until the key is within the desired
range.
Since our specified range does not include lower-case letters, the
GUI (provided) will change strings to upper case. You can find the
ASCII table at http://www.asciitable.com/, or many other places on
the Internet.
The second approach, due to Giovan Battista Bellaso (b 1505, d
1581), uses a key word, where each character in the word specifies
the offset for the corresponding character in the message, with the
key word wrapping around as needed.
So for the string ABCDEFG and the key word CMSC, the key word is
first extended to the length of the string, i.e., CMSCCMS. Then A
is replaced by ‘A’ offset by ’C’, i.e., ASCII 65+67=132. The range
of the characters is also specified, and again we’ll say ‘ ‘ to ‘_’
(i.e., ASCII 32 to ASCII 95). The range is then 95-32+1=64. In our
example, the offset is “wrapped” by reducing 132 by the range until
it is the allowable range. 132 is adjusted to 132-64=68, or
character ‘D’ in the encrypted phase. Then the same logic is
applied to the second letter of the plain text ‘B’ shifted by the
second letter of the key word ‘M’. This results in the character
‘O’ as the second letter in the encrypted phase, and so on. In each
approach, if the resulting integer is greater than 95 (the top of
our range), the integer is “wrapped around” so that it stays within
the specified range. The result is “DOVGHSZ”.
Your program will implement several methods that are specified in
the file “CryptoManager.java”. A Graphical User Interface is
provided, as well as a test file, that you should use to make sure
your methods work correctly. Be sure to follow the naming exactly,
as the tests will not work otherwise.
There are several features of Java that we have not yet covered in
class. Just follow the syntax specified in this document and in the
file CryptoManager.java. First, the required methods are “static”,
which just means that they are available from the class even if an
instance has not been created. To call a static method, for
example, “public static void myMethod();” the syntax is
CryptoManager.myMethod();. Another feature that may be useful in
this project is the method charAt(i) on a string, which returns a
character at position i of a string (zero-based). So
“thisString”.charAt(3); would return the char ‘s’.
Notes:
⦁ Proper naming conventions: All constants, except 0
and 1, should be named. Constant names should be all upper-case,
variable names should begin in lower case, but subsequent words
should be in title case. Variable and method names should be
descriptive of the role of the variable or method. Single letter
names should be avoided.
Indentation: It must be consistent throughout the program and must
reflect the control structure
In: Computer Science
In: Computer Science
THIS IS FOR DEVC++. I use the 5.11 version
Write a program to take input of scores for Chemistry, Biology and English for a student and display the average with 2 decimal places if all of the three scores are in the range between 1 and 100 inclusive. Program should also display the course name for which scores are entered out of range telling Average couldn't be calculated.
Following is a sample run:
Enter scores for Chemistry, Biology and English between 1 and
100:
45
89
96
Avg score is 76.67
Following is another sample run:
Enter scores for Chemistry, Biology and English between 1 and
100:
900
78
89
Average cannot be calculated because Chemistry Scores were not in
range.
Following is another sample run:
Enter scores for Chemistry, Biology and English between 1 and
100:
89
767
8787
Average cannot be calculated because Biology Scores were not in
range.
Average cannot be calculated because English Scores were not in
range.
Following is another sample run:
Enter scores for Chemistry, Biology and English between 1 and
100:
87
90
-1
Average cannot be calculated because English Scores were not in
range.
In: Computer Science
Convert "hello world" into hex "hello world" in hex = 68656c6c6f20776f726c64
encrypt the above binary content with a 4 bit block cipher whose codebook consists of 6, 0, 13, 4, 3, 1, 14, 8, 7, 12, 9, 15, 5, 2, 11, 10 (The codebook is simply the output blocks in the order of the integers corresponding to the 16 possible input blocks).
What will the encrypted output be for this text?
In: Computer Science