Questions
For each of the following Unix system calls, give a condition that causes it to fail:...

For each of the following Unix system calls, give a condition that causes it to fail: open, read, fork, execve, unlink.

In: Computer Science

create overloaded functions called lastValue. The first function should take as a parameter a string and...

create overloaded functions called lastValue. The first function should take as a parameter a string and the second function should take as a parameter an int. each of you functions should return an int value. in the case of the function that takes the string as an argument you will return the ascii value of the last character in the string. in the case of the function that takes an int parameter your function will return the last digit in the number c++

In: Computer Science

1. Write a program that computes the smallest and largest of a set of values that...

1. Write a program that computes the smallest and largest of a set of values that are stored in an array. Ask the user for the set size (and hence the array size). Populate the array with user input. (Java language)

In: Computer Science

FOR JAVA Define a class QuadraticExpression that represents the quadratic expression ax^2 + bx + c:...

FOR JAVA

Define  a class  QuadraticExpression that represents the quadratic expression ax^2 + bx + c:
You should provide the following methods

  (1) default constructor which initalizes all the coefficients to 0

  (2) a constructor that takes three parameters
          public QuadraticExpression(double a, double b, double c) 
  
  (3) a toString() method that returns the expression as a string. 
   
  (4) evaluate method that returns the value of the expression at x 
    public double evaluate(double x)
    
  (5) set method of a, b, c  
       public void setA(double newA)
       public void setB(double newB)
       public void setC(double newC)
     
  (6) public static QuadraticExpression sum( QuadraticExpression q1, QuadraticExpression q2): 
      returns a new expression that is the sum of the q1 and q2

  (7) public static QuadraticExpression scale( double r, QuadraticExpression q)
      returns a new expression that is r times q

  (8) public int numberOfRoots()
      returns number of roots, where 3 means infite number of roots
     
  (9) public void add( QuadraticExpression q)
      add q to the calling expression object

  (10) public double smallerRoot() throws Exception
   Depending on the equation ax^2 + bx + c = 0: 
      if no roots, throw exception
      if single root, return it
      if two roots, return  the smaller root
      if infinite root, return -Double.MAX_VALUE

  (11) public double largerRoot() throws Exception
      if no roots, throw exception
      if single root, return it
      if two roots, return  the larger root
      if infinite root, return Double.MAX_VALUE
  
  (12) equals method
      This should OVERRIDE equals method from Object class
  
      return true if two expressions have same a, same b and same c

  (13) clone 
       return a copy of the calling object
   

  (14) use javadoc style comments for the class, and the methods
  
       At minimum, include the author,  parameters and return types for each method. 
       
  (15) use javadoc to generate document for your class
  
  (16) test your class:
       you can write your own main to test your code;
    
        but you have to pass the test in QuadraticExpressionTest.java 

   (17) submit  
     a. QuadraticExpression.java
     b. QuadraticExpression.html
      on blackboard.

   (18) turn in printout of
  a. QuadraticExpression.java
 b. the output of your program

Please!! test before posting it

In: Computer Science

Consider the following schema: Suppliers(sid: integer, sname: string, address: string) Parts(pid: integer, pname: string, color: string)...

Consider the following schema:

Suppliers(sid: integer, sname: string, address: string)

Parts(pid: integer, pname: string, color: string)

Catalog(sid: integer, pid: integer, cost: real)

The key fields are underlined, and the domain of each field is listed after the field name. Therefore sid is the key for Suppliers, pid is the key for Parts, and sid and pid together form the key for Catalog. The Catalog relation lists the prices charged for parts by Suppliers.

WRITE THE FOLLOWING QUERIES IN RELATIONAL ALGEBRA WITH BASIC OPERATORS AND AGGREGATE FUNCTIONS ONLY

MEANS IF THE QUERIES CANNOT FULLY EXPRESSED BY BASIC OPERATORS, USE AGGREGATES.

1. Find the names of suppliers who supply some red part.

2. Find the sids of suppliers who supply some red or green part.

3. Find the sids of suppliers who supply some red part or are at 221 Packer Street.

4. Find the sids of suppliers who supply some red part and some green part.

5. Find the sids of suppliers who supply every part.

6. Find the sids of suppliers who supply every red part.

7. Find the sids of suppliers who supply every red or green part.

8. Find the sids of suppliers who supply every red part or supply every green part.

9. Find pairs of sids such that the supplier with the first sid charges more for some part than the supplier with the second sid.

10. Find the pids of parts supplied by at least two different suppliers.

11. Find the pids of the most expensive parts supplied by suppliers named Yosemite Sham.

12. Find the pids of parts supplied by every supplier at less than $200. (If any supplier either does not supply the part or charges more than $200 for it, the part is not selected.)

In: Computer Science

MySQL Multiple Choice Answer as soon as possible 1. Which one of the following is not...

MySQL
Multiple Choice
Answer as soon as possible

1. Which one of the following is not a Replication Data Format?
(a) Row
(b) Mixed
(c) Statement
(d) Sync

2. When executing the following statement on the master:
UPDATE enormous_table SET col1 = 0;
Which replication format would be more efficient?
(Assume enormous_table is a large table with millions of rows)
(a) Statement
(b) Row
(c) Neither

3. When executing the following statement on the master:
INSERT INTO summary_table(col1, col2, sum_col3)
SELECT col1, col2, sum(col3)
FROM enormous_table
GROUP BY col1, col2;
Which replication format would be more efficient?
(Assume enormous_table is a large table with millions of rows)
(a) Statement
(b) Row
(c) Neither

4. Which one of the following is a way to detect if there is an error replicating data on the slave?
(a) Run SHOW MASTER STATUS and Look for an error description in LAST_SQL_ERROR in the results.
(b) Run SHOW MASTER STATUS and Look for an error description in INVALID_COMMAND_FOUND in the results.
(c) Run SHOW SLAVE STATUS and Look for an error description in INVALID_COMMAND_FOUND in the results.
(d) Run SHOW MASTER STATUS and Look for an error description in SYNCING = NO in the results.
(e) Run SHOW SLAVE STATUS and Look for an error description in LAST_SQL_ERROR in the results.

5. Which one of the following is the correct command to skip the next command in the binlog on the slave (this is sometimes used to skip a command that is causing a replication error)?
(a) SET GLOBAL SQL_SLAVE_SKIP = YES;
(b) SET GLOBAL SQL_SLAVE_SKIP_COMMANDS = 1;
(c) SET GLOBAL SQL_SLAVE_SKIP_ON_ERROR = YES;
(d) SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;

6. Which one of the following is the command for temporarily disabling the binlog on the master so you can run a statement without it getting replicated to the slave(s)?
(a) SET REPLICATE_TO_SLAVE = NO;
(b) SET SQL_LOG_BIN = 0;
(c) SET ENABLE_BINLOG = 0;
(d) SET DISABLE_BINLOG = YES;

In: Computer Science

Respond to the following in a minimum of 175 words: Discuss your response to the following:...

Respond to the following in a minimum of 175 words: Discuss your response to the following: What are some qualitative tools used to analyze data in Microsoft® Excel®? How do these tools assist users with their business decisions? Provide an example from a past or current work experience when the use of these tools would have helped the outcome of your spreadsheet. How was the data analyzed differently? Explain your answer.

In: Computer Science

6) What is the 6-bit 1's complement representation of -1710? Write your answer in the format...

6) What is the 6-bit 1's complement representation of -1710?

Write your answer in the format 0bXXXX... Where X's are binary digits. Include leading 0's (zeroes).

7)  What is the 6-bit sign-magnitude representation of -1710?

Write your answer in the format 0bXXXX... Where X's are binary digits. Include leading 0's (zeroes).

9)  What is the 8-bit 1's complement representation of 1710?

Write your answer in the format 0xHHHH... Where H's are hexidecimal digits. Include leading 0's (zeroes). Write hexidecimal digits, A-F, in capitals.

10)  What is the 8-bit sign-magnitude representation of 1710?

Write your answer in the format 0xHHHH... Where H's are hexidecimal digits. Include leading 0's (zeroes). Write hexidecimal digits, A-F, in capitals.

In: Computer Science

USE PYTHON ONLY Zeller’s congruence is an algorithm developed by Christian Zeller to calculate the day...

USE PYTHON ONLY

Zeller’s congruence is an algorithm developed by Christian Zeller to calculate the day of the week. The formula is

h = (q + 26(m+1)//10 + k + k//4 +j//4 +5j) % 7

where

- h is the day of the week (0: Saturday, 1: Sunday, 2: Monday, 3: Tuesday, 4: Wednesday, 5: Thursday, 6: Friday).
- q is the day of the month.
- m is the month (3: March, 4: April, ..., 12: December). January and February are counted as months 13 and 14 of the previous year.
- j is year//100.
- k is the year of the century (i.e., year % 100).

Write a program that prompts the user to enter a year, month, and day of the month, and then it displays the name of the day of the week.

In: Computer Science

Write a PHP script to display in frequency all the words in the submitted paragraph. Convert...

Write a PHP script to display in frequency all the words in the submitted paragraph.
Convert the string to an array of words.
Count the number of times the words are used. Hint: array_count_values($arrayname)
Sort the array in frequency order.
Print the array to the screen. Hint: print_r($arrayname)

In: Computer Science

Visual C# 2017 Write a program named Eggs that declares four variables of type int to...

Visual C# 2017

Write a program named Eggs that declares four variables of type int to hold the number of eggs produced in a month by each of four chickens, and assign a value to each variable.

Sum the eggs, then display the total in dozens and eggs. For example, if the total number of eggs was 95, the output would be 95 eggs is 7 dozen and 11 eggs.

Note: For final submission ensure that the total number eggs equals 127.

In: Computer Science

My code in python keeps failing when the investment is 12 and the market price is...

My code in python keeps failing when the investment is 12 and the market price is 1. I'd like to keep my code, just fix the issue. Thank you.

This is what the automated tests keep saying:

market_price = 1

available_funds = 12

Expected output: Buy 2 shares

Actual output : Hold Shares

We can profit most by buying 2 shares

--------------------------------------------------------------

I'm stopping the tests for now,

because it looks like you still have some work to do.

You should review the test feedback above,

and then work to resolve these issues in your code.

I Ran 7 of 8 test(s).

Your code passed 4 test(s).

Your code failed 3 test(s).

Continue to build on your success,

and focus on creating the simplest code

that will pass just one more test.

Here is my Code:

def trade_action(current_stock, purchase_price, current_price, investment):
# Write your code here.
if purchase_price>= current_price:
investment-=10
number_shares = investment/current_price
profits= (number_shares*current_price-purchase_price)-10
if profits >= 0:
return number_shares
else:
return "Hold Shares"
elif current_price>= purchase_price:
if current_price-purchase_price*current_stock-10>0:
return "Sell Shares"
else:
return "Hold Shares"

As stated. The problem is when the computer inputs 12 for investment and 1 for market share, the program returns Hold Shares, when it is suppose to return purchase 2 shares.

Project Challenge: Automatic Stock Trader

DIRECTIONS

Many investment management companies are switching from manual stock trading done by humans to automatic stock trading by computers. You've been tasked to write a simple automatic stock trader function that determines whether to buy, sell, or do nothing (hold) for a particular account. It should follow the old saying "Buy low, sell high!"

This function takes 4 input parameters in this order:

  1. current_shares - current number of shares of this stock in the account (int).
  2. purchase_price - price (per share) paid for current stock in the account (float).
  3. market_price - current market price (per share) of stock in the account (float).
  4. available_funds - maximum amount the client is willing to spend on a stock purchase (float).

Any transaction (buy or sell) costs $10. This $10 must be paid out of the available_funds for a purchase, or out of the proceeds of a stock sale. Be sure to account for this fee in your profit calculations.

A purchase would be considered profitable when the current market price is lower than the purchase price, and the available funds will allow us to buy enough shares so that the difference in value will cover the $10 transaction fee. In this case the function should return the string "Buy # shares" where # is an integer representing the number of shares to purchase.

A sale would be considered profitable when the current market price is higher than the purchase price, and the value gained by selling the shares will cover the $10 transaction fee. In this case the function should return the string "Sell # shares" where # is an integer representing the number of shares to sell.

If neither a buy nor a sell would be profitable, then the function should return the string "Hold shares."

Here are some test cases that your function should satisfy:  

Test 1 Test 2 Test 3 Test 4 Test 5 Test 6
current_shares 10 20 15 1 10 1
purchase_price 100 2 12 1 1 1
market_price 1 1 1 11 3 12
available_funds 10 21 12 0 30 0
OUTPUT Hold shares Buy 11 shares Buy 2 shares HoldShares Sell 10 shares Sell 1 shares

Rationale for test cases:

Test 1
Even though the current market price is very low (compared to the purchase price), after paying the $10 transaction fee, we would not have any funds left to buy shares; so we can only hold.

Test 2
After paying the $10 transaction fee, there are enough funds remaining to buy 11 shares. At a purchase_price vs. market_price difference of $1 per share, our 11 shares represent a value gain of $11 dollars, which is $1 more than the $10 transaction fee - so we come out $1 ahead.

Test 3
After paying the $10 transaction fee, there are enough funds remaining to buy 2 shares. At a purchase_price vs. market_price difference of $11 per share, our 2 shares represent a value gain of $22 dollars, which is $12 more than the $10 transaction fee - so we come out $12 ahead.

Test 4
Selling our 1 share for $11 will leave us with just $1 after we pay the $10 transaction fee. That is the same as what we paid for it, and we won't make any profit - so we should hold.

Test 5
With a market_price vs. purchase_price vs. difference of $2 per share, we stand to make $20 from the sale of our 10 shares. This is $10 more than the price of the transaction fee, so we will come out $10 ahead - therefore we should sell all 10 shares.

Test 6
Our 1 share is worth $11 more than we paid for it at the current market price. The $11 dollars obtained by selling that share now will still leave us with a profit of $1 after paying the $10 transaction fee. Profit is profit, so we should sell.

Things to think about when you’re designing and writing this program:

  1. Look for opportunities to use variables as a way to name things, and to break larger more complex expressions down into simpler expressions.
  2. Spend some time choosing your names carefully. Names should be descriptive.
  3. Try to design and write your code a few lines at a time. Design and write a few lines, then run some tests to see if these lines are doing what you want them to do. If they are not, then analyze and correct them before you move on to the next few lines of code.

In: Computer Science

1. Write a program that computes the smallest and largest of a set of values that...

1. Write a program that computes the smallest and largest of a set of values that are stored in an array. Ask the user for the set size (and hence the array size). Populate the array with user input.

In: Computer Science

1. If an attacker sends a large number of probe packets via IPv4, you can block...

1. If an attacker sends a large number of probe packets via IPv4, you can block them by blocking the attacker’s IP address. Now suppose the attacker uses IPv6 to launch the probes; for each probe, the attacker changes the low-order 64 bits of the address. Can these probes be blocked efficiently? If so, what do you have to block? Might you also be blocking other users? 2. Suppose someone tried to implement ping6 so that, if the address was a link-local address and no interface was specified, the ICMPv6 Echo Request was sent out all non-loopback interfaces. Could the end result be different than conventional ping6 with the correct interface supplied? If so, how likely is this?

In: Computer Science

Write a binary search algorithm in C language by performing following steps: Prompt the user to...

  1. Write a binary search algorithm in C language by performing following steps:
  2. Prompt the user to enter the number of array elements (say, N).  
  3. Read the N different values (define these values to be of type integer).  
  4. Read the element (integer value) which you want to search.
  5. Invoke a function to display the values in the array. The function should take the array reference and number of elements as arguments and should have the return type as void. The function should loop through the array and print the array values one per line.
  6. Invoke a function to search in the array using binary search (this function should take the array reference and number of elements as the arguments and the search element). The binary search function should have the return type as integer and it should return the array index when the search value is found, otherwise it should return -1.
  7. The main program should print a message if the search value is found and the corresponding position in the array where it was found. If the search value was not found, then the main program should also print a message saying that the search value does not exist in the given array.

In: Computer Science