In: Computer Science
2. Describe ASK, explain how it works and why we use it:
3. Explain what PCM does and how it works:
4. Which of the following networking device(s) block(s) broadcast traffic, thus dividing networks into separate subnets? (Hint: only OSI Network layer devices can divide networks into separate subnets): Routers, Switches, Wireless Access Points (bridges)
5. List the three types of multiplexing from the text and explain how they work:
. List two network layer protocols and explain what they do:
6. Explain what the acronym “ARQ” stands for and explain how it works:
7. The Session and Presentation layers are explicit layers in the OSI model, but are embedded within the Application layer of the TCP/IP protocol stack. Explain what the Session and Presentation layers do.
Session:
Presentation:
8. How does the application layer handle security?
In: Computer Science
In: Computer Science
Write a DFA simulator using the C++ programming language. Please refer to the following UDACITY website if you do knot know C++. This is a free online tutorial for learning C++.
Example input file... (ab)*
0
0a1
ob2
1a2
1b0
2a2
2b2
Total of five (5) files: c++ file; output file (text file); input file (textile containing the DFa); a diagram of the DFA; a screen shot illustrating that your code compiled correctly with timestamp.
In: Computer Science
Follow the UML diagram and directions on the attached file to create a RectangularPrism class and a RectangularPrismDemo class. --------------------------------------------------------------------------------------------------------------------------------------- RectangularPrism |
- length: double - width: double - height: double |
+ RectangularPrism() + RectangularPrism(l:double,w:double, h:double) + setLength(l:double):void + setWidth(w:double):void + setHeight(h:double):void +getLength():double +getWidth():double +getHeight():double +getVolume():double +getSurfaceArea():double +toString():String ---------------------------------------------------------------------------------------------------------------------
|
In: Computer Science
Complete the method sortSuits(). This method takes one argument:a deck of cards (Stack<String> deck).It should return an ArrayList of Stacks, each stack representing all the cards of one suit(i.e., if you have four suits -Spades,Hearts,Clubs,Diamonds, it should return ArrayLists of Spades,Hearts,Clubs,and Diamonds). The returned ArrayList should be in the same order as the SUITSarray. Use a loop to look at each card, determine its suit (methods such as peek()/pop()and String.contains()may be helpful), and move the card from the deck to the stack associated with its suit.
package L2;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Stack;
public class CardSort {
public static final String[] RANKS =
{"Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"};
public static final String[] SUITS =
{"Spades","Hearts","Clubs","Diamonds"};
public static void main(String[] args) {
/* DO NOT EDIT THE MAIN METHOD
*/
//make a deck of cards, should have
52 cards
Stack<String> deck =
makeDeck();
System.out.println("New deck:
"+deck.size()+" cards");
System.out.println(deck);
System.out.println();
//automatically shuffles the deck,
don't need to code this
Collections.shuffle(deck);
System.out.println("Shuffled deck:
"+deck.size()+" cards");
System.out.println(deck);
System.out.println();
//create an ArrayList of Stacks,
each representing all the cards of one suit
ArrayList<Stack<String>> bySuit =
sortSuits(deck);
for(int i = 0; i <
bySuit.size(); i++) {
//each new stack
should have 13 cards, all the same suit
System.out.println(SUITS[i]+": "+bySuit.get(i).size()+"
cards");
System.out.println(bySuit.get(i));
System.out.println();
}
//the deck should now be
empty
System.out.println("Deck is empty?
"+deck.isEmpty()+" ("+deck.size()+" cards)");
}
public static Stack<String> makeDeck() {
/* YOUR CODE HERE */
int n = SUITS.length *
RANKS.length;
String[] deck = new
String[n];
for (int i = 0; i <
RANKS.length; i++) {
for (int j = 0;
j < SUITS.length; j++) {
deck[SUITS.length*i + j] = RANKS[i] + " of " +
SUITS[j];
}
} Stack<String> stack2 =
new Stack<String>();
for(String text:deck) {
stack2.push(text);
}
return (Stack<String>) stack2
;
}
public static ArrayList<Stack<String>>
sortSuits(Stack<String> deck) {
return null;
}
}
In: Computer Science
1. From the statement “Lincoln is the 16th US president”, we can come up with the following designs. Which one is most appropriate?
a. Two independent Classes: Lincon and President.
b. Two Classes: Lincon and President, with Lincon subclass of President.
c. A class President, with Lincon being an object of the class President.
d. None of the above.
4.An advantage of inheritance is that
a. All methods in a super class can be inherited by its subclasses.
b. All instance variables in a super class can be accessed by subclasses.
c. An object of a subclass can be treated as an object of the superclass.
d. None of the above.
6. Pair programming refers to the style where two programmers switching their roles in coding and real-time reviewing. This encourages:
a. Collective code ownership
b. Cross-learning among peers
c. Code critics and refinement
d. All of the above
In: Computer Science
The goal is to
Random Number Seeding
We will make use of the random_shuffle() function from the standard algorithm library.
You can use srand() function provided in with a seed value so that we get random yet reproducible results. srand() seeds the pseudo random number generator for the rand() function. For a seed value to call as argument of the srand() function, you can use time(0) as seed ( defined in ). The time() function returns time_t value, which is the number of seconds since 00:00 hours, Jan 1, 1970 UTC (i.e. the current unix timestamp). Since value of seed changes with time, every time a new set of random number is generated.
Employee list construction
An employee has last name, first name, birth year and hourly wage information stored in the struct. All of this information should be taken from standard input using c++ console I/O for all the employees in the array. You should print prompt messages to ask user for information on each of the field in the struct.
Now we turn our attention to random_shuffle(). This function requires three arguments: a pointer to the beginning of your array, a pointer to 1 past the end of the array, and a pointer to the function. The function will be myrandom which I have provided you. Usage is very simple, and there are many resources on how to call this function on the Internet.
Once you have your shuffled array of employees, we want to select 5 employees from the original array of employees. Again, create this however you see fit, but please use the first 5 employees in your array.
A C++ array initializer could be helpful here. For example, consider the following code:
int arr[5] = {1,2,3,4,5};
This C++ syntax allows us to explicitly define an array as it is created.
Once you’ve built an array of 5 employees, we want to sort these employees by their last Name. Notice the function headers at the top of the file:
bool name_order(const employee& lhs, const employee& rhs);
Specifically, the last function is what we need for sorting.
This is because Employee struct don’t have a natural ordering like letters in the alphabet or numbers. We need to define one. That is the job of name_order(): it takes in 2 const employee references and returns true if lhs < rhs (left-hand side, right-hand side) and false otherwise. Notice that in C++ we have a dedicated bool type we can use to represent truthiness. C++ string library has less than “<” operator overloaded so you can simply compare two strings like string1 < string2.
Implement this function and pass the name of the function as the third argument to the sort() function. The first two arguments are a pointer to the beginning of your array and a pointer to 1 past the end.
C++ I/O and iomanip
Finally, print out the sorted array using range based for loop( see lecture), C++ I/O (cout <<) and some basic I/O manipulators. I/O manipulators are functions which alter an output stream to produce specific types of formatting. For example, the setw() function linked in the resources allows you to specify the absolute width of what is printed out. For example, if I use the following code:
cout << setw(5) << “dog”;
The result would be the string “dog“ printed to the terminal. Notice the 2 spaces at the end that pad the length to 5 characters.
You should set the width and make each line printed right aligned.
When you print out the hourly wages, you should print it as double value with “fixed”, “showpoint” and “setprecision(n)” where it prints the double value with n places after the decimal point.
Sample Output
Doe, Jane
1990
24.68
Smith, John
1989
25.50
Starter code:
#include <iostream>#include <iomanip>#include <algorithm>#include <sstream>#include <string>#include <cstdlib>using namespace std;typedef struct Employee{string lastName;string firstName;int birthYear;double hourlyWage;}employee;bool name_order(const employee& lhs, const employee& rhs);int myrandom (int i) { return rand()%i;}int main(int argc, char const *argv[]) { // IMPLEMENT as instructed below /*This is to seed the random generator */ srand(unsigned (time(0))); /*Create an array of 10 employees and fill information from standard input with prompt messages*/ /*After the array is created and initialzed we call random_shuffle() see the *notes to determine the parameters to pass in.*/ /*Build a smaller array of 5 employees from the first five cards of the array created *above*/ /*Sort the new array. Links to how to call this function is in the specs *provided*/ /*Now print the array below */ return 0;}/*This function will be passed to the sort funtion. Hints on how to implement* this is in the specifications document.*/bool name_order(const employee& lhs, const employee& rhs) { // IMPLEMENT}
In: Computer Science
I am trying to write code for a program in Visual Studo using Visual Basic programming language that computes the factorial of an entered number by using a For Loop. My problem is that it keeps re-setting the variable for Factorial. Below is my code if anyone can help. I want it to multiply the given number by that number - 1, then continuing to do so until it hits zero without multiplying by zero.
Private Sub BtnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
Dim Factorial As Integer = Integer.Parse(txtNumber.Text)
For i = Factorial To 2 Step -1
Factorial = i * (i - 1)
Next
txtFactorial.Text = Factorial.ToString()
End Sub
In: Computer Science
Error detection/correction C
Objective:
To check a Hamming code for a single-bit error, and to report and correct the error(if any)
Inputs:
1.The maximum length of a Hamming code
2.The parity of the check bits (even=0, odd=1)
3.The Hamming code as a binary string of 0’s and 1’s
Outputs:
1.The original parity bits (highest index to lowest index, left to right)
2.The new parity bits (highest index to lowest index, left to right)
3.The bit-wise difference between the original parity bits and the new parity bits
4.The erroneous bit (if any)
5.The corrected Hamming code (if there was an error)
Specification:
The program checks a Hamming code for a single-bit error based on choosing from a menu of choices, where each choice calls the appropriate procedure, where the choices are:
1) Enter parameters
2)Check
Hamming code
3) Quit program
To use the Math library, use: “#include <math.h>” to access various functions, such as pow(base, exp), log(number), etc.To perform the XOR function, use the operator “^”.
To use the String library, use: “#include <string.h>” to access various functions, such as strlen(string) which returns an integer representing the
length of a string of characters.
If necessary, include the flag “-lm” when you compile i.e. gcc filename.c–lm to be able to utilize the math library.
skeleton:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
/* declare global var's including a dynamic array of characters to store
the Hamming code,
original parity bits, and new parity bits*/
/*************************************************************/
void "OPTION 1"()
{
/* prompt for maximum length of hamming code and even/odd parity */
printf("\nEnter the maximum length of the Hamming code: ");
/* allocate memory for Hamming code */
return;
}
/*************************************************************/
void "OPTION 2"()
{
/* declare local var's */
/* prompt for Hamming code */
/* calculate actual length of input Hamming code, number of parity bits,
and highest parity bit */
/* Allocate memory for original and new parity bits */
/* Map parity bits within Hamming code to original parity bit array */
/* Calculate new parity bits */
/* OUTER LOOP: FOR EACH PARITY BIT */
/* initialize parity bit to even/off parity */
/* MIDDLE LOOP: FOR EACH STATING BIT OF A CONSECUTIVE SEQUENCE */
/* INNER LOOP: FOR EACH BIT OF A SEQUENCE TO BE CHECKED */
/* ignore original parity bit */
/* update new parity bit value based on Hamming code bit
checked */
} /* END INNER LOOP */
/* Map new parity bit value to new parity bit array */
} /* END OUTER LOOP */
/* Calculate error bit by XORing original and new parity bits from
respective arrays, weighted properly */
/* Print original parity bits & new parity bits and bit-wise difference */
/* If error, correct the bit and print which bit is in error and corrected
Hamming code */
/* Else if no error, print message of no code bit error */
return;
}
/******************************* OPTIONAL ************************/
void "FREE MEMORY"()
{
/* If daynamic array representing Hamming code is not NULL, free the
memory */
return;
}
/*****************************************************************/
int main()
{
/* print menu of options, select user's choice, call appropriate
procedure, and loop until user quits */
return 1;
}
Please do not use abcdef as variable names
In: Computer Science
this is a python code:
QUESTION 3:
Imagine that the IRA is giving stimulus package in the COVID-19
season. The package amount is determined by the number of adults in
the family and the total amount of salary the family gets.
Each adult will get 1200 dollars if the total salary is 100000 or less.
Each adult will get 800 dollars if the total salary is 150000 or less.
Write a python program to ask the user the number of adults in the family and total number of family salary and determine the total amount of stimulus package the IRA will provide for that family.
QUESTION 4:
Write a program that will ask user length and width of a right triangle and find the area of the right angled triangle. The formula for finding the area of right angle triangle is
ab/2. Also find out the result if you calculate as (ab)/2. Is it the same? If it is same, why it is the same. If it is not the same, why it is not the same.
In: Computer Science
In: Computer Science
“Managing Configuration and Data for Effective Project Management.” The process protocol model consists of thirteen (13) steps from Inception to Feedback.
What are the steps?
Can any be skipped in this process model?
In: Computer Science
Going through a basic tutorial on bringing in data from a URL in Python. So far, I've imported Citi Bike station data and converted the JSON file to a Python dictionary named datadict...
import requests
response =
requests.get("https://gbfs.citibikenyc.com/gbfs/en/station_information.json")
if response.status_code != 200:
print("Error with website. If problem persists, contact your
Facilitator!")
else:
print("Data download successful")
datadict = response.json()
print(datadict.keys())
print(datadict['data'].keys())
datadict['data']['stations']
The task is to now...
In the code cell below, write and evaluate code to extract the latitude and longitude of every bike station, and store the result in a variable named coordinates. Store the data in a numpy array of shape (N,2), where N is the total number of stations, and 2 reflects the number of columns — store all the longitudes in the first column and all the latitudes in the second column.
Carry out this data extraction however you see fit. The basic steps you will need to carry out are:
After importing numpy, the remaining set of steps above can be done in one line, using a list comprehension to extract the desired pair of fields from each station entry and then converting the list to a numpy array using the np.array function. But if you'd rather break out each step separately within a for loop, that would work too. When you are finished, you should have a numpy array with shape approximately equal to (1000, 2), since there should be approximately 1000 stations in the full array of coordinates (although that number can change over time as new stations are added or removed). Print the shape of the array to determine how many stations are included in the dataset that you downloaded.
In: Computer Science
Alice is sending message “HIDE” to Bob. Perform encryption and decryption using RSA algorithm, with the following information: parameters p=11,q=5, e=7
Present all the information that you will need to encrypt and decrypt only the first letter from text
In: Computer Science