Questions
double_vowels Given a string, return a copy of the string with all of the vowels doubled....

double_vowels

Given a string, return a copy of the string with all of the vowels doubled. Consider the five letters 'aeiou' as vowels.


double_vowels('pencil') → 'peenciil'
double_vowels('xyzzy') → 'xyzzy'
double_vowels('catalog') → 'caataaloog'

middle_hash

Given a string, do three hash marks '###' appear in the middle of the string? To define middle, we'll say that the number of chars to the left and right of the '###' must differ by at most one.


middle_hash('aa###bb') → True
middle_hash('aaa###bb') → True
middle_hash('a###bbb') → False

fence_post

Given two strings, fence and post, return a string made up of count instances of post, separated by instances of fence.

<i>Note</i>: This is an example of the classic "fence post" programming problem. It's a variant of the off-by-one-error (OBOE).


fence_post('X', 'Word', 3) → 'WordXWordXWord'
fence_post('And', 'This', 2) → 'ThisAndThis'
fence_post('And', 'This', 1) → 'This'

balanced_x_y

We'll say that a String is xy-balanced if for all the 'x' chars in the string, there exists a 'y' char somewhere later in the string. So 'xxy' is balanced, but 'xyx' is not. One 'y' can balance multiple 'x's. Return true if the given string is xy-balanced.


balanced_x_y('aaxbby') → True
balanced_x_y('aaxbb') → False
balanced_x_y('yaaxbb') → False

repeated_prefix

Given a string, consider the prefix string made of the first N chars of the string. Does that prefix string appear somewhere else in the string? Assume that the string is not empty and that N is in the range 1..len(str).


repeated_prefix('abXYabc', 1) → True
repeated_prefix('abXYabc', 2) → True
repeated_prefix('abXYabc', 3) → False

In: Computer Science

Context switching occurs when a task surrenders the CPU to another task or is preempted by...

Context switching occurs when a task surrenders the CPU to another task or
is preempted by another task. Use program examples (pseudo code plus Gantt
charts) to show a scenario for each of the cases.

In: Computer Science

Below is what I have to do. This is all performed in SQL. I have written...

Below is what I have to do. This is all performed in SQL. I have written a bunch of code, that I have also provided. Any help is appreciated

Exercises

Complete each of the following exercises. If you are unsure how to accomplish the task, please consult the coursework videos where there are explanations and demos.

  1. Use built in SQL functions to write an SQL Select statement on fudgemart_products which derives a product_category column by extracting the last word in the product name. For example
    1. for a product named ‘Leather Jacket’ the product category would be ‘Jacket’
    2. for a product named ‘Straight Claw Hammer’ the category would be ‘Hammer’

Your select statement should include product id, product name, product category and product department.

  1. Write a user defined function called f_total_vendor_sales which calculates the sum of the wholesale price * quantity of all products sold for that vendor. There should be one number associated with each vendor id, which is the input into the function. Demonstrate the function works by executing an SQL select statement over all vendors calling the function.
  2. Write a stored procedure called p_write_vendor which when given a required vendor name, phone and optional website, will look up the vendor by name first. If the vendor exists, it will update the phone and website. If the vendor does not exist, it will add the info to the table. Write code to demonstrate the procedure works by executing the procedure twice so that it adds a new vendor and then updates that vendor’s information.
  3. Create a view based on the logic you completed in question 1 or 2. Your SQL script should be programmed so that the entire script works every time, dropping the view if it exists, and then re-creating it.
  4. Write a table valued function f_employee_timesheets which when provided an employee_id will output the employee id, name, department, payroll date, hourly rate on the timesheet, hours worked, and gross pay (hourly rate times hours worked).

Written Code

use fudgemart_v3
go

--Question 1
--This runs but doesn't supply correct output
select * from fudgemart_products
select right(product_name, charindex(' ', product_name)) as product_category from fudgemart_products
go


---Runs but returns NULL for product_Category
select product_id, product_name, product_department
from fudgemart_products
order by product_id
declare @product_name as varchar(20)
select right(@product_name, charindex(' ',@product_name)) as product_category

print len(@product_name)


---question 2-----

drop function dbo.f_vendor_sales
go

declare @vendor_id int
set @vendor_id = 1
select count(*) from fudgemart_products where product_vendor_id = @vendor_id
go

--Function says it is completed
create function dbo.f_total_vendor_sales(
   @vendor_id int --input
   ) returns int as
begin
   declare @count int
   set @count = (select count(*) from fudgemart_products.dbo.product_wholesale_price where product_vendor_id = @vendor_id)
   return @count --output
end
go

---When i attempt function, I get invalid object name

select product_vendor_id, product_wholesale_price,
   dbo.f_total_vendor_sales(product_vendor_id) as total_vendor_sales
   from fudgemart_products


----For question 3-------
create procedure p_write_vendor
(
   @vendor_name varchar (50),
   @vendor_phone varchar (20),
   @vendor_website varchar (100)
   ) as
if exists ( select 1 from fudgemart_vendors
               where vendor_name = @vendor_name
               or vendor_phone = @vendor_phone
               or vendor_website = @vendor_website)
   begin
       update fudgemart_vendors
       set vendor_name =@vendor_name,
           vendor_phone = @vendor_phone,
           vendor_website = @vendor_website
       where vendor_name = @vendor_name
       or vendor_phone = @vendor_phone
       or vendor_website = @vendor_website
   end
else
   begin
       insert into fudgemart_vendors values (@vendor_name, @vendor_phone, @vendor_website)
   end

In: Computer Science

Give short answers or Define the following questions [in your own words]: 1. Compare the difference...

Give short answers or Define the following questions [in your own words]:

1. Compare the difference between Attack and Threat.

2. List out 6 different types of attackers

3. Briefly explain 5 different types of vulnerabilities and give examples for each.

4. Explain in brief the different goals of Security.

5. What are the various classes of Threat? Explain in your own words.

6. Briefly explain the principle of Least Privilege with an example scenario.

7. What are fail-safe defaults? Give 3 examples for the same [You are allowed to google to find your examples]

8. Give a brief note about Open design. Give the benefits and disadvantages of Open source code.

9. Why is it required to Separate privileges? Give a brief note on the same.

10. Why do you need to introduce Mandatory vacations for staffs during investigation process?

In: Computer Science

Explain a least 4 kinds of wireless communication subsystems that were used by NASA and SoaxeX...

Explain a least 4 kinds of wireless communication subsystems that were used by NASA and SoaxeX for their recent space expedition

In: Computer Science

Explain the viruses and malware

Explain the viruses and malware

In: Computer Science

In C# creating a math challenge program using +, -, /, * Create a few fields:...

In C#

creating a math challenge program using +, -, /, *

  1. Create a few fields: A readonly array of possible operators, the problem's operator, and each of the two (2) terms

In: Computer Science

Write a menu driven program in Java (OOP) That contain class for Botique. Data members include...

Write a menu driven program in Java (OOP)
That contain class for Botique.
Data members include code ,colour , size ,Quantity
Your class should contains app accessors and mutators method
Your class should contain Parametric and non-parametric constructors (use constructor chaining)
Your class should have input and display method.


In: Computer Science

Write a java program which can randomly generate a permutation of the integer {1, 2, 3,...

Write a java program which can randomly generate a permutation of the integer {1, 2, 3, ..., 48,49,50}. Use the most efficient sorting algorithm to sort the list in an acceding order.

In: Computer Science

Python Coding Question: Find the minimum number of coins that make a given value.

Python Coding Question: Find the minimum number of coins that make a given value.

In: Computer Science

linux use the command dmesg, use grep to filter and then redirect just the lines with...

linux

use the command dmesg, use grep to filter and then redirect just the lines with the word Linux in them from the output generated by the dmesg command. redirect this output to a file at the path PutFileHere/Dmesgoutput.txt. What command did you use to do this, if there is no output choose a different word to grep for in the output of this command and substitute that word.

In: Computer Science

This LinkedListUtil class tests various usages of the LinkedList class. The single param is an array...

This LinkedListUtil class tests various usages of the LinkedList class. The single param is 
an array of string. You will create a linked list with the string elements and return the 
linked list with all but the 1st two elements removed.

Note: In this question use a for or while loop instead of the suggested iterator. You should also ignore CodeCheck’s error message about a missing class (LinkedListUtil.class). Your code still needs to pass all test cases.

EDIT: you want to remove all besides the first 2 elements. So only the first 2 elements should be returned

LinkedListUtil.java

import java.util.LinkedList;
import java.util.ListIterator;

/**
This LinkedListUtil class tests various usages of the LinkedList class
*/
public class LinkedListUtil
{
/**
Constructs a LinkedListUtil.
@param list is the initialized list
*/
public LinkedListUtil(LinkedList list)
{
this.list = list;
}

/**
deletes all but the first two linked list enries
*/
public void processList()
{
// TODO: create a list iterator and remove all but the first two elements
}


private LinkedList list;

// this method is used to check your work
public static LinkedList check(String[] values)
   {  
LinkedList list = new LinkedList();
for (String s : values)
       list.addLast(s);

LinkedListUtil tester = new LinkedListUtil(list);
tester.processList();
return list;
}

}

In: Computer Science

Question #1 Data Modelling is the primary step in the process of database design. Compare and...

Question #1

Data Modelling is the primary step in the process of database design. Compare and contrast Conceptual data model versus Physical data model. Illustrates with help of example to list down data (entities), relationship among data and constraints on data.

Question #2

What strategic competitive benefits do you see in a company’s use of extranets?

Question #3

Explain how Internet technologies are involved in developing a process in one of the functions of the business? Give an example and evaluate its business value.

Question #4

What are the basic differences between HRM, Intranet and Internet in terms of Domain and Network Communication Scope?

All information are written. there is no more information.

In: Computer Science

Objective Make a function to serve as a Craps dice game simulator. If you are not...

Objective

Make a function to serve as a Craps dice game simulator. If you are not familiar Craps is a game that involves rolling two six-sided dice and adding up the total. We are not implementing the full rules of the game, just a function that returns the value of BOTH dice and their total.

Details

In the function you create: Make a function that uses pointers and pass by reference to return THREE separate outputs (arrays are not allowed). Inside the function you will call rand() to represent a random dice roll of a six sided dice. One output will be the first call to rand() and represent the first dice roll. The second output will be a second call to rand() and represents the second dice roll. The third output is the total of the two other outputs added together.

You may choose either options for defining the function:

Option A:

  • RETURN: void function
  • PARAMETERS: Three variables that use pass by reference. Two of them are set to the dice rolls within the function. The third is the total of the two dice rolls added together.

Option B:

  • RETURN: int value - Total of the two dice rolls.
  • PARAMETERS: Two variables that use pass by reference, each one is set to a random dice roll.

In the Main Function: Call srand() to initialize the pseudo-random algorithm. Create three variables to hold your outputs, the two dice rolls and the total. In a for loop call your dice roll function FIVE times, each time it should set the three variables to new values. Also within the for loop print the values of the dice rolls and the total.

  • No input is required from the user this time. Everything that is output is done from the random function.
  • Add #include <time.h> to your code.
  • In the main function the call to srand looks like:
    • srand(time(NULL));
  • In the dice roll function the call to represent a six sided dice looks like:
    • rand() % 6 + 1
  • Do not just call printf from within the dice roll function! Demonstrate that you can receive multiple outputs from the same function

In: Computer Science

C Programming How do you read in a text file line by line into a an...

C Programming

How do you read in a text file line by line into a an array.

example, i have the text file containing:

line 1: "qwertyuiop"

line 2: "asdfghjkl"

line 3: "zxcvbnm"

Then in the resulting array i get this:

array:"qwertyuiopasdfghjklzxcvbnm"

In: Computer Science