Questions
Question 1 (25pts): Consider the string “data and program analytics”. Write a program to perform the...

Question 1 (25pts):

Consider the string “data and program analytics”. Write a program to perform the following actions

  • Find the index of the character ‘p’ in the given string
  • Print the character which is present at index number seven
  • Find the length of the String
  • Split the string at every occurrence of a whitespace
  • Replace the word “data” in the original string with “information” using a standard string manipulation function. Your output after the manipulation should be “information and program analytics”

Question 2 (15 pts):

List1 = [3, 4, 5, 20, 5]

  • Find the index of the second 5
  • Find the last element of this list

Question 3 (15 pts):

Set1 = {1, 2, 3, 4}, Set2={4, 5, 6}

  • Print all elements that appear in both sets
  • Print those elements that appear in either set
  • Print all elements that appear in Set1 but not Set2

Question 4 (15 pts):

L = [('',), (), ('apple', 1), (), ("Paul", "Merage', 2020, "MSBA212"), ("d")]

Write a Python program to remove an empty tuple(s) from a list of tuples.

Expected outcome is:

[('',), ('apple', 1), ('Paul', 'Merage', 2020, 'MSBA212'), 'd']

Question 5 (15 pts):

  • Reverse words in the string "one apple a day keeps the doctors away" and print the new string
  • Sort the words in the string "one apple a day keeps the doctors away" alphabetically and then print the new string.

Question 6 (15 pts):

Two given lists [1,2,4,8,5,10] and [2,4,5,8,12,15], write a program to make a list whose elements are intersection of the above given lists.

In: Computer Science

Instructions Complete the lab using “for loop”. Do not write the code in multiple programs. All...

Instructions

  • Complete the lab using “for loop”.
  • Do not write the code in multiple programs. All the 3 methods should be written in 1 program.
  1. Write a java program calls the following methods:
    1. printStars(): Takes an int (n) as parameter and prints n stars (*) using for loop.
    2. Multiples(): Takes an int (n) as parameter and prints first 10 multiples n in a single line using for loop.
    3. hasAnEvenDigit: Takes an int (n) as parameter and returns whether n has at least one digit whose value is even. Return true if the number has at least one even digit else false if none of the digits are even. For example, the call hasAnEvenDigit(33267) should return true and hasAnEvenDigit(7591) should return false.

[Hint: n%10 returns the last digit and n/10 returns everything except the last digit]

In: Computer Science

Computer Science Question 1: DO NOT USE ANY NON-STANDARD LIBRARY. o All the required libraries have...

Computer Science Question 1:

DO NOT USE ANY NON-STANDARD LIBRARY. o All the required libraries have already been included. O DO NOT INCLUDE ANY OTHER LIBRARY INTO THE CODE. o DO NOT ALTER THE NAMES OF THE C FILES PROVIDED. o DO NOT ALTER THE NAMES AND PROTOTYPES OF THE FUNCTIONS.DO NOT ALTER ANY OF THE CODE! JUST ADD WHAT NEEDS TO BE ADDED FOR IT TO WORK! Please copy and paste the whole solution. Please read the code below and complete what it is asking.

This is the code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define SIZE 20

// A regular function to check and return the maximum value between two integers
int max(int a, int b);

// A recursive function for recursively find and return the maximum value in an array of integers
int maximumValue(int a[], int size);

int main(void) {

        srand(time(NULL));

        int myArray[SIZE];

        // COMPLETE THIS PART
        // ******************
        // populate the array with positive random integers less than 100





        // COMPLETE THIS PART
        // ******************
        // Print out the elements of the array in one line





        // COMPLETE THIS PART
        // ******************
        // Find and print out the maximum value in the array by calling the recursive function maximumValue



}

int max(int a, int b) {

        // COMPLETE THIS PART
        // ******************
        // if a is greater than or equal to b, return a, otherwise return b


}

int maximumValue(int a[], int size) {

        // COMPLETE THIS PART
        // ******************
        // Base case and recursive part using an if-else statement.
        // Base case:
        //              If there is only one element in the current array, return it.
        // Recursive part:
        //              Call the max function with two parameters, the first element of the array and maximumValue of the rest of the array.

In: Computer Science

A transport logistics company (using trucks) is planning to purchase 30 laptops for its employees. (i)...

A transport logistics company (using trucks) is planning to purchase 30 laptops for its employees.

(i) Explain (in detail) what is meant by the term “total cost of ownership” in this acquisition?

(ii) For support purposes, you are asked to prepare a plan to prevent users from encountering problems (or even misusing) the new laptops. Select five different end user problem types and describe the common issues and preventative measures.

In: Computer Science

write an essay comparing and contrasting as mentioned below Radio vs newspapers. what are the similarities...

write an essay comparing and contrasting as mentioned below

Radio vs newspapers. what are the similarities and differences?

In: Computer Science

C# Write a program in C# that prompts the user for a name, Social Security number,...

C#

Write a program in C# that prompts the user for a name, Social Security number, hourly pay rate, and number of hours worked. In an attractive format, dis- play all the input data as well as the following: » Gross pay, defined as hourly pay rate times hours worked » Federal withholding tax, defined as 15% of the gross pay » State withholding tax, defined as 5% of the gross pay » Net pay, defined as gross pay minus taxes

In: Computer Science

Part 4: Explain in a couple of paragraphs how public key encryption can be used to...

Part 4: Explain in a couple of paragraphs how public key encryption can be used to implement a digital signature. Be sure you are very clear on when a private key is used and when a public key is used.

Part 5: Generally, a digital signature involves encrypting a cryptographic hash, or digest, generated from the message. Explain why we do not encrypt the message itself. You can answer this question in one sentence.

Part 6: For each of the following scenarios below, tell what type of encryption is most appropriate and in a sentence or two explain the reasoning for your choice.
1. Alice wants to send a confidential message to Bill, whom she has never met and who lives in a distant country.
2. Charlie wants to be sure that no one but he can see the financial and medical records he has stored on his computer.
3. David needs a way to check that large computer files stored on corporate servers have not been modified.
4. Eddard uses a "cloud" backup service; he wants to be sure the operators of the service cannot read his files.
5. Frank needs to send a message to George. The message need not be confidential, but George must be assured that it actually came from Frank.

In: Computer Science

Implementing Polynomials using Singly Linked List in C++ The Term Class Create a class to represent...

Implementing Polynomials using Singly Linked List in C++

  1. The Term Class

    Create a class to represent a term in an algebraic expression. As defined here, a term consists of an integer coefficient and a nonnegative integer exponent. E.g.

    • in the term 4X2, the coefficient is 4 and the exponent 2
    • in -6X8, the coefficient is -6 and the exponent 8

    Your class will have a constructor that creates a Term object with a coefficient and exponent passed as parameters, and accessor methods that return the coefficient and the exponent


    II. The Polynomial Class

    Now create a class to represent a polynomial. As defined here, a polynomial is a sequence of terms. E.g.

    1. 3X2 + 4X4 + X6
    2. 2 + 5X2 + 6X3 + 2X7
    3. 4X10

    The terms of polynomial 1 are (3,2), (4,4) and (1,6). The terms of polynomial 2 are (2,0), (5,2), (6,3) and (2,7). Polynomial 3 has only one term (4,10)

    F To receive credit for this assignment, your class must use a generic “List of Term” to store the terms of a Polynomial object

    Your class will have a constructor that creates an empty list and additional methods to do each of the following:

    1. insert a new term in its proper place in a polynomial (see “Additional Specifications,” below)

    2. return all the terms of a polynomial as a single line string, as shown here:

    3x^2 + 4x^4 + x^6

    3. delete a term from a polynomial (see “Additional Specifications,” below)

    4. Compute and return the derivative of all the polynomial


5. reverse the order of the terms in a polynomial (see “Additional Specifications,” below)


III. The Test Class

The main method of your test class will create a Polynomial object and then read and process a series of operations

The operations are:

1. INSERT X Y

Insert a new term with coefficient X and exponent Y into its proper place in the polynomial

(insert method : adds terms to the list in descending order of power)

2. DELETE X Y

Remove the term with coefficient X and exponent Y from the polynomial

3. REVERSE

Reverse the order of the terms of the polynomial

4. 1st DEV

          to find the first derivatives of the polynomial

   2nd DEV

         to find the second derivatives of the polynomial

Each operation is to be carried out by calling a method of the Polynomial class

Each operation read must be “echo printed” to the screen

After each operation, print the updated polynomial by calling the toString() method

For the Derivatives operation, print the string returned
-----------------------------------------------------------------------------

In: Computer Science

DESIGN A FLOWCHART IN THE APPLICATION FLOWGORITHM Number Analysis Program Design a program that asks the...

DESIGN A FLOWCHART IN THE APPLICATION FLOWGORITHM

Number Analysis Program Design a program that asks the user to enter a maximum of 20 numbers. The program should store the numbers in an array and then display the following data: -The lowest number in the array. -The highest number in the array. -The total of the numbers in the array. -The average of the numbers in the array.

PLEASE AND THANK YOU

In: Computer Science

subject DBA use mysql workbench and select my guitar shop database as default schema Problem8 Write...

subject DBA

use mysql workbench and select my guitar shop database as default schema

Problem8

Write a script that implements the following design in a database named my_web_db:

    users                                                       downloads                                                                 Products

*user_id INT                                         * download_id INT                                                   * product_id INT                     

*email_address VARCHAR(100)          * user_id INT                                                         * product_name VARCHAR(45)

*first_name VARCHAR(45)                  *download_date DATETIME

*last_name VARCHAR(45)                  * filename VARCHAR(50)

                                                               *product_id INT

Details

  • In the downloads table, the user_id and product_id columns are the foreign keys.
  • Include a statement to drop the database if it already exists.
  • Include statements to create and select the database.
  • Include any indexes that you think are necessary.
  • Specify the utf8 character set for all tables.
  • Specify the InnoDB storage engine for all tables.

Solution fill in the blanks :-

______DATABASE ____________ ;

CREATE DATABASE my_web_db ___________ ;

USE my_web_db;

_________ TABLE _______

    user_id       INT          PRIMARY _______ AUTO_INCREMENT,

    email_address VARCHAR(100) UNIQUE,

    first_name    VARCHAR(45) NOT NULL,

    last_name     VARCHAR(45) NOT NULL

) ___________ ;

__________ products (

    product_id   INT         ________ AUTO_INCREMENT,

    product_name VARCHAR(45) UNIQUE

__________

____________

    download_id   INT         PRIMARY KEY,

    ____________       INT         NOT NULL,

    download_date DATETIME    NOT NULL,

    filename      __________ NOT NULL,

    product_id    INT         NOT NULL,

    ___________ fk_downloads_users

_____________ KEY (user_id )

        REFERENCES users (user_id),

_______________

_______________ product_id)

        REFERENCES products _______________

) ENGINE = _________ ;

In: Computer Science

what does this code means. Explain each line (briefly) Book.findOneAndUpdate[{isbn:req.params.isbn}, {$set:{authFName:req .body.authFName, authLName: req.body.authLName}, {new:true}}

what does this code means. Explain each line (briefly)

Book.findOneAndUpdate[{isbn:req.params.isbn},

{$set:{authFName:req .body.authFName,

authLName: req.body.authLName}, {new:true}}

In: Computer Science

Multiples of 2 and 3: write a c++ program Using a while loop, write a program...

Multiples of 2 and 3: write a c++ program Using a while loop, write a program that reads 10 integer numbers. The program shall count how many of them are multiples of 2, how many are multiples of 3, and how many are NOT multiples of either 2 or 3. The output should be similar to the one shown below.

In: Computer Science

In C++, please build a simple Distance Vector program that will communicate with N partners and...

In C++, please build a simple Distance Vector program that will communicate with N partners and do the following. (NOTE: All connections between a server and clients should be TCP/IP socket.)

  1. You will run N instances on your machine
  2. Each instance will run on a different port (instance 1 will run on port 18181, instance 2 on port 18182, instance 3 on port 18183, etc)
  3. The program will start by reading in the appropriate neighbors file and vector file.
  4. The program will ONLY read vectors where the fromNode is equal to that node. For instance, node 1 will only read in vectors where node1 is the fromNode.
  5. The program will support the following requests from clients:
    1. Show files at the server’s current directory: ‘print
      1. This will print the current vector table on a node.
      2. ONLY print valid vectors (don’t print uninitialized ones)
    2. Download files: ‘refresh
      1. This will force the current node to send its vector table to all its neighbors.
    3. Upload files: ‘update
  1. This will be of the form: Update fromNode toNode cost
  2. Update checks that the toNode is the current node. If it is not it is ignored
  3. Update then checks if the toNode-fromNode exists in vector table. If it does not it is added and neighbors are notified
  4. If the pair is in the table, and if the new cost is less than the old cost, that cost is stored and the neighbors are notified.

In: Computer Science

Discuss modern trends in local area networks?

Discuss modern trends in local area networks?

In: Computer Science

2. Write python code for the below instructions (don’t forget to use the keyword “self” where...

2. Write python code for the below instructions (don’t forget to use the keyword “self” where appropriate in your code):

A. Define a Parent Class called Person

a. Inside your Person class, define new member variables called name, age, and gender.   Initialize these variables accordingly.

b. Define the constructor to take the following inputs: name, age, and gender.   Assign these inputs to member variables of the same name.

B. Define Child Class called Employee that inherits from the Person Class

a. Inside your Child class, define new member variables called title and salary.   Initialize these variables accordingly.

b. Define the constructor to take the following inputs: name, age, gender, title, and salary.   Assign these inputs to Class member variables of the same name. Note, you will need to specifically call the Parent constructor method inside the Child constructor, passing the appropriate inputs to the Parent constructor.

C. Instantiate an Employee object called George with the following inputs: name = “George”, age = 30, gender = “Male”, title = “Manager”, and salary = 50000.

D. Print out the object’s name, age, gender, title, and salary in one print statement to the console window. Your output should look like:

“George's info is: Name is George, Age is 30, Gender is Male, Title is Manager, and Salary is 50000”

In: Computer Science