Questions
Write a function which takes in X and Y arrays, a column number, and a threshold....

Write a function which takes in X and Y arrays, a column number, and a threshold. The function should return arrays X0 and Y0 containing all rows where the value in the specified column falls strictly below the threshold, as well as arrays X1 and Y1 containing all rows where the value in the specified column is above or equal to the threshold.(use numpy)

def split_on_feature(X_test, Y_test, column, thresh):
## TYPE ANSWER HERE

In: Computer Science

public class Square {    public static final int NUM_OF_SIDES = 4;    private float length;...

public class Square {
   public static final int NUM_OF_SIDES = 4;
   private float length;
  
   public Square(float l) {
       setLength(l);
   }
  
   public void setLength(float l) {
       if(l >= 0) {
           length = l;
       }
   }
  
   public float getLength() {
       return length;
   }
      
   //TODO - Add method to calculate add return area
  
  
   //TODO - Add method to calculate add return perimeter
  
   public String toString() {
       return String.format("Square [length: %f]", length);
   }
  
}

I am trying to add the formulas for area and perimeter but using the info provided each time I get a compile error indicating I am missing a main method. How would I go about adding these formulas without getting more compile errors?

In: Computer Science

Computer Science: Data Structures and Algorithms Practice: Construct a C++ program that takes two SQUARE matrices,...

Computer Science: Data Structures and Algorithms

Practice:

Construct a C++ program that takes two SQUARE matrices, and multiplies them and produces a new matrix:

Example:

[Matrix A] * [Matrix B] = [Matrix C]

(A 3x3 is the most preferred example to use)

(The first two matrices, A and B can be fixed numbers, hard-coded into the program. as opposed to user input)

Display Matrix C, also (cout etc.)

In: Computer Science

c++ code Reverse the order of elements in a vector of integers using two functions: (a)...

c++ code

Reverse the order of elements in a vector of integers using two functions:

(a) The first function takes the input vector a and return a vector b with the input data but in the reverse order, e.g. input: 1, 2, 3 and output 3, 2, 1.

(b) The second function is a recursive one and it reverses the input data in place (without using an additional vector).

In: Computer Science

You have been asked to create a list of all MAC addresses and corresponding IP addresses...

You have been asked to create a list of all MAC addresses and corresponding IP addresses and computer names in your network. Propose at least two methods for performing this task. Your network has almost 100 computers in a Windows Server 2016 domain network with statically assigned IP addresses. Using the tools available in Windows Server 2016, carry out the procedure you think will work best. Write a short report of your results and submit it to your instructor.

In: Computer Science

// The QuickCopy company currently makes 100,000 copies per year // at 15 cents each. //...

// The QuickCopy company currently makes 100,000 copies per year
// at 15 cents each.
// They expect to increase the number of copies produced
// by 4 percent per year each year for the next 10 years,
// starting with this year.
// They also expect the price of each copy to increase
// by 3 cents per year, starting with this year.
// This program displays the company's expected
// income for each of the next 10 years.
// Modify it to be more efficient.
start
Declarations
num year = 1
num copies = 100000
num price = 0.15
num total = 0
num COPIES_INCREASE = 0.04
num PRICE_INCREASE = 0.03
copies = copies + copies * COPIES_INCREASE
price = price + price * PRICE_INCREASE
total = total + copies * price
output year, total
year = year + 1
copies = copies + copies * COPIES_INCREASE
price = price + price * PRICE_INCREASE
total = total + copies * price
output year, total
year = year + 1
copies = copies + copies * COPIES_INCREASE
price = price + price * PRICE_INCREASE
total = total + copies * price
output year, total
year = year + 1
copies = copies + copies * COPIES_INCREASE
price = price + price * PRICE_INCREASE
total = total + copies * price
output year, total
year = year + 1
copies = copies + copies * COPIES_INCREASE
price = price + price * PRICE_INCREASE
total = total + copies * price
output year, total
year = year + 1
copies = copies + copies * COPIES_INCREASE
price = price + price * PRICE_INCREASE
total = total + copies * price
output year, total
year = year + 1
copies = copies + copies * COPIES_INCREASE
price = price + price * PRICE_INCREASE
total = total + copies * price
output year, total
year = year + 1
copies = copies + copies * COPIES_INCREASE
price = price + price * PRICE_INCREASE
total = total + copies * price
output year, total
year = year + 1
copies = copies + copies * COPIES_INCREASE
price = price + price * PRICE_INCREASE
total = total + copies * price
output year, total
year = year + 1
copies = copies + copies * COPIES_INCREASE
price = price + price * PRICE_INCREASE
total = total + copies * price
output year, total
stop

In: Computer Science

You are the IT director for XYZ Manufacturing. Your company is a B2B (business-to-business) organization that...

You are the IT director for XYZ Manufacturing. Your company is a B2B (business-to-business) organization that supplies auto parts to General Motors. There are 200 employees at XYZ Manufacturing with a headquarters in Detroit, Michigan, and field offices in Omaha, Nebraska; Austin, Texas; and Orlando, Florida. There are over 10,000 items in the inventory for XYZ Manufacturing and you receive raw material (i.e. steel, plastic, wiring, etc.) from China.

XYZ Manufacturing has been struggling for years with inadequate computer resources to track inventory and handle user requests from internal management, orders and invoices from General Motors, orders and invoices from your suppliers, and management reports. There is clearly an inability to store and retrieve complex “big data,” and recently there have been frequent security breaches. Your CIO is extremely frustrated with this situation and is looking for an alternative approach to providing IT services. She has asked you for input on this investigation.

Write a paper that describes advantages and disadvantages that cloud computing offers to XYZ Manufacturing. Include a sensible, detailed strategy to migrate to cloud computing, addressing the issues of performance, scalability, and economic factors.

Your paper should be 8-10 pages in length. Include at least five credible references.

In: Computer Science

Using PopG, set the fitness of the aa homozgyote to 0.95 (so s = 0.05). Set...

Using PopG, set the fitness of the aa homozgyote to 0.95 (so s = 0.05). Set the population size to 5. Run the program for 500 generations with 5 populations, no mutation, no migration and a starting allele frequency of 0.50 for the A allele. How many populations at generation 500 were fixed for the A allele?

In: Computer Science

Python #Exercise 1 #Assign the following first names to a variable name as a list: peter,paul,mary...

Python

#Exercise 1
#Assign the following first names to a variable name as a list: peter,paul,mary
#Assign the following last names to a variable name as a list: ng,lo,lau
#Display each first name in a separate line in turn so that your screen shows (ignore the #):
#peter
#paul
#mary
#Combine the elements in the list in turn so that you display the full names of each person in separate lines
#Output should look like the following (ignore the #):
#peter ng
#paul lo
#mary lau

#Exercise 2
#Assign the following grades to a variable name as a list: 80,90,100,70
#Use the sum() function to total up the values in the list and assign the sum to a variable
#Use the len() function to get the length of the list and assign the length to a variable
#Compute the average grade using the sum and length of the list and assign the average to a variable
#Convert the list length, list sum, and average to strings
#Display the results of your calculation in the following format using the + concatenator
#Your total score for [length of list] grades is [sum of list] resulting in an average of [average grade]!
#Ask the user for a grade using the prompt: New grade? (include a space after the ?)
#Convert the new grade into an integer
#Add the new grade to the end of the existing list using the append method
#Remove the second grade in the list using the pop method
##Use the sum() function to total up the values in the list and assign the sum to a variable
#Use the len() function to get the length of the list and assign the length to a variable
#Compute the average grade using the sum and length of the list and assign the average to a variable
#Display the results of your calculation in the following format using the + concatenator
#Your total score for [length of list] grades is [sum of list] resulting in an average of [average grade]!

#Exercise 3
#Ask the user for a student's name using the propmt: Student Name? (include a space after the ?)
#Assign the following grades to a variable name as a list: 80,90,70,85
#Assign the following requirement codes to a variable name as a list: HW,MT,IC,HW
#Ask the user for a new requirement code using the prompt: Requirement Code? (include a space after the ?)
#Ask the user for a new grade using the prompt: Grade? (include a space after the ?)
#Add the new requirement code to the requirement code list using the append method
#Convert the new grade to an integer
#Add the new grade to the end of the list of grades using the append method
#Display the following: Grades for: [student name -- input from user in first instruction of Exercise 3]
#Combine the information from both lists to display each pair of requirement code and grade in a separate line
#The output should have the following structure:
#[requirement code] [grade]
#For example, the first two lines should read (ignore the #)
#HW 80
#MT 90
#etc until the last items in the lists -- There should be 5 lines of code-grade pairings
#Get the sum of the grades list using the sum() function
#Get the length of the grades list using the len() function
#Compute the student's average grade using the sum and length
#Convert the average grade to a string
#Use the + concatenator to display the following statement (ignore the #):
#[student name]: your average grade is [average grade]!
#If student name is George Smith and average grade is 80, output should be:
#George Smith: your average grade is 80!

In: Computer Science

Provide the following operations in four-digit 10's complement math. All input is in ten's complement. Provide...

Provide the following operations in four-digit 10's complement math. All input is in ten's complement. Provide the output in both ten's complement and decimal sign and magnitude formats.

a) 1818 + 9282 =

b) 1808 + 1188 =

c) 1929 - 1818 =

d) 2828 - 9988 =

In: Computer Science

Python Pierrette is at Legoland. She enjoys all the rides but hates to wait in lines....

Python

Pierrette is at Legoland. She enjoys all the rides but hates to wait in lines. Thanks to technology,

she has an app that tells her for each ride i a time ti when there is no line. However, she wants to

take the rides in increasing fun factor order. Pierrette assigns each ride i a fun factor fi . What is

the maximum number of rides she can take?

Make sure that your code runs in O(n2 ) time in order to pass all the test cases (n is the number of

rides)

# [last_name] [first_name], [student_ID]

from typing import List


def max_num_rides(rides: List[List[int]]) -> int:

    """Calculate the maximum number of rides one can take with given constraints.

    Pierrette is at Legoland. She enjoys all the rides but hates to wait in lines.

    Thanks to technology, she has an app that tells her for each ride a time when

    there is no line. However, she wants to take the rides in increasing fun factor

    order. Pierrette assigns each ride a fun factor. This function takes pairs of

    times and fun factors for all the rides, and returns the maximum number of

    rides Pierrette can take.

    Arguments:

        rides (list): A list of [time, fun factor] pairs. For each ride, the rides

            list contains a pair of time and fun factor. Both the time and the fun

            factor are integers. Assume that it takes no time to take a ride. You

            may further assume that all the time values are distinct and all the

            fun factor values are also distinct.

    Returns:

        int: The maximum number of rides Pierrette can take.

    Examples:

        >>> print(max_num_rides([[2, 5], [1, 3]]))

        2

        >>> print(max_num_rides([[4, 2], [42, 3], [59, 8], [12, 4], [1, 5], [5, 7]]))

        3

    """

    pass # FIXME

In: Computer Science

You are the IT director for XYZ Manufacturing. Your company is a B2B (business-to-business) organization that...

You are the IT director for XYZ Manufacturing. Your company is a B2B (business-to-business) organization that supplies auto parts to General Motors. There are 200 employees at XYZ Manufacturing with a headquarters in Detroit, Michigan, and field offices in Omaha, Nebraska; Austin, Texas; and Orlando, Florida. There are over 10,000 items in the inventory for XYZ Manufacturing and you receive raw material (i.e. steel, plastic, wiring, etc.) from China.

XYZ Manufacturing has been struggling for years with inadequate computer resources to track inventory and handle user requests from internal management, orders and invoices from General Motors, orders and invoices from your suppliers, and management reports. There is clearly an inability to store and retrieve complex “big data,” and recently there have been frequent security breaches. Your CIO is extremely frustrated with this situation and is looking for an alternative approach to providing IT services. She has asked you for input on this investigation.

Write a paper that describes advantages and disadvantages that cloud computing offers to XYZ Manufacturing. Include a sensible, detailed strategy to migrate to cloud computing, addressing the issues of performance, scalability, and economic factors.

Your paper should be 8-10 pages in length. Include at least five credible references.

In: Computer Science

Learning Objectives After the successful completion of this learning unit, you will be able to: Implement...

Learning Objectives

After the successful completion of this learning unit, you will be able to:

  • Implement syntactically correct C++ arrays.
  • Solve a variety of standard problems using arrays.

Array Practice

I recommend that before you begin the assignment you write as many of these small ungraded programming challenges as you can. You should at least write 2 or 3 of them. They are a good way to gradually build up your confidence and skills. Of course, you'll have to write a program to test each function as well. Note that none of these functions should include any input or output!

  • Write a function named noNegatives(). It should accept an array of integers and a size argument. It should return true if none of the values are negative. If any of the values are negative it should return false

            bool noNegatives(const int array[], int size);
    
  • Write a function named absoluteValues(). It should accept an array of integers and a size argument. It should replace any negative values with the corresponding positive value.

            void absoluteValues(int array[], int size);
    
  • Write a function named eCount. It should accept an array of chars and a size argument. It should return the number of times that the character 'e' shows up in the array.

            int eCount(const char array[], int size);
    
  • Write a function named charCount. It should be similar to eCount, but instead of counting 'e's it should accept a third argument, a target char. The function should return the number of times the target char shows up in the array.

            int charCount(const char array[], int size, char targetChar);
    
  • Write a method named isSorted. It should accept an array of integers and a size argument. It should return true if the values are sorted in ascending order. False if they are not.

            bool isSorted(const int array[], int size);
    
  • Write a method named equalNeighbors. It should accept an array of chars and a size argument. It should return true if there are two adjacent elements in the array with equal values. If there are not, it should return false.

            bool equalNeighbors(const char array[], int size);
    

This is not a homework assignment, so feel free to post your code to one of these (not more than one) to the forum at any time.

For Credit

Assignment 4.1 [45 points]

Write a program that reads five (or more) cards from the user, then analyzes the cards and prints out the category of hand that they represent.

Poker hands are categorized according to the following labels: Straight flush, four of a kind, full house, straight, flush, three of a kind, two pairs, pair, high card.

To simplify the program we will ignore card suits, and face cards. The values that the user inputs will be integer values from 2 to 9. When your program runs it should start by collecting five integer values from the user and placing the integers into an array that has 5 elements. It might look like this:

Enter five numeric cards, no face cards. Use 2 - 9.
Card 1: 8 
Card 2: 7
Card 3: 8
Card 4: 2
Card 5: 3

(This is a pair, since there are two eights)

No input validation is required for this assignment. You can assume that the user will always enter valid data (numbers between 2 and 9).

Since we are ignoring card suits there won't be any flushes. Your program should be able to recognize the following hand categories, listed from least valuable to most valuable:

Hand Type Description Example
High Card There are no matching cards, and the hand is not a straight 2, 5, 3, 8, 7
Pair Two of the cards are identical 2, 5, 3, 5, 7
Two Pair Two different pairs 2, 5, 3, 5, 3
Three of a kind Three matching cards 5, 5, 3, 5, 7
Straight 5 consecutive cards 3, 5, 6, 4, 7
Full House A pair and three of a kind 5, 7, 5, 7, 7
Four of a kind Four matching cards 2, 5, 5, 5, 5

(A note on straights: a hand is a straight regardless of the order. So the values 3, 4, 5, 6, 7 represent a straight, but so do the values 7, 4, 5, 6, 3).

Your program should read in five values and then print out the appropriate hand type. If a hand matches more than one description, the program should print out the most valuable hand type.

Here are three sample runs of the program:

Enter five numeric cards, no face cards. Use 2 - 9.
Card 1: 8 
Card 2: 7
Card 3: 8
Card 4: 2
Card 5: 7
Two Pair!
Enter five numeric cards, no face cards. Use 2 - 9.
Card 1: 8 
Card 2: 7
Card 3: 4
Card 4: 6
Card 5: 5
Straight!
Enter five numeric cards, no face cards. Use 2 - 9.
Card 1: 9 
Card 2: 2
Card 3: 3
Card 4: 4
Card 5: 5
High Card!

Additional Requirements

1) You must write a function for each hand type. Each function must accept a const int array that contains five integers, each representing one of the 5 cards in the hand, and must return "true" if the hand contains the cards indicated by the name of the function, "false" if it does not. The functions should have the following signatures.

bool  containsPair(const int hand[])
bool  containsTwoPair(const int hand[])
bool  containsThreeOfaKind(const int hand[])
bool  containsStraight(const int hand[])
bool  containsFullHouse(const int hand[])
bool  containsFourOfaKind(const int hand[])

Note that there are some interesting questions regarding what some of these should return if the hand contains the target hand-type and also contains a higher hand-type. For example, should containsPair() return true for the hand [2, 2, 2, 3, 4]? Should it return true for [2, 2, 3, 3, 4]? [2, 2, 3, 3, 3]? I will leave these decisions up to you.

2) Of course, as a matter of good practice, you should use a constant to represent the number of cards in the hand, and everything in your code should still work if the number of cards in the hand is changed to 4 or 6 or 11 (for example).  Writing your code so that it does not easily generalize to more than 5 cards allows you to avoid the objectives of this assignment (such as traversing an array using a loop). If you do this, you will receive a 0 on the assignment.

3) You do not need to write a containsHighCard function. All hands contain a highest card. If you determine that a particular hand is not one of the better hand types, then you know that it is a High Card hand.

4) Do not sort the cards in the hand. Also, do not make a copy of the hand and then sort that.

5) An important objective of this assignment is to have you practice creating excellent decomposition.  Don't worry about efficiency on this assignment. Focus on excellent decomposition, which results in readable code. This is one of those programs where you can rush and get it done but end up with code that is really difficult to read, debug, modify, and re-use. If you think about it hard, you can think of really helpful ways in which to combine the tasks that the various functions are performing.  5 extra credit points on this assignment will be awarded based on the following criteria: no function may have nested loops in it. If you need nested loops, the inner loop must be turned into a separate function, hopefully in a way that makes sense and so that the separate function is general enough to be re-used by the other functions. Also, no function other than main() may have more than 5 lines of code. (This is counting declarations, but not counting the function header, blank lines, or lines that have only a curly brace on them.) In my solution I was able to create just 3 helper functions, 2 of which are used repeatedly by the various functions.

These additional criteria are intended as an extra challenge and may be difficult for many of you. If you can't figure it out, give it your best shot, but don't be too discouraged. It's just 5 points. And be sure to study the posted solution carefully.

Suggestions

Test these functions independently. Once you are sure that they all work, the program logic for the complete program will be fairly straightforward.

Here is code that tests a containsPair function:

int main() {
        int hand[] = {2, 5, 3, 2, 9};

        if (containsPair(hand)) {
                cout << "contains a pair" << endl;
        }
}

Submit Your Work

Name your source code file according to the assignment number (a1_1.cpp, a4_2.cpp, etc.). Execute the program and copy/paste the output that is produced by your program into the bottom of the source code file, making it into a comment. Use the Assignment Submission link to submit the source file. When you submit your assignment there will be a text field in which you can add a note to me (called a "comment", but don't confuse it with a C++ comment). In this "comments" section of the submission page let me know whether the program works as required.

Keep in mind that if your code does not compile you will receive a 0.

In: Computer Science

You have just been put in charge of safety at your plant. The probability of an...

You have just been put in charge of safety at your plant. The probability of an injury occuring on any given day is p. Your boss says that once the company has 10 totoal days in which at least one injury is reported the insurance premium triples. To plan financially, she wants to know how many days to expect until the insurance premium is going to triple. Write a class called SafetyAnalysis.java that does the following:

a. Reads in a value of p from the user. Checks if it is a double and a feasible probability.

b. Determines if there is an injury each day. To do this, generate a random number between 0 and 1. If the number you generated is less than p then there was an injury. Otherwise, there was not an injury on that day.

c. Continue determining if there was an injury each day until a total of 10 days worth of injuries have occurred (hint: use a loop where you don’t know how many iterations are required).

d. Repeat b. - c. 1000 times (hint: use a loop where you do know how many iterations are required). Return the average number of days it takes until 10 total injuries occur. (hint: each time you complete c., you have a new value to include in your average) e. Report the average number of days over the 1000 experiments that it takes until 10 days of injuries occur. Print this value to the screen with the appropriate labeling information

In: Computer Science

A local biologist needs a program to predict population growth. The inputs would be: The initial...

A local biologist needs a program to predict population growth. The inputs would be: The initial number of organisms The rate of growth (a real number greater than 1) The number of hours it takes to achieve this rate A number of hours during which the population grows For example, one might start with a population of 500 organisms, a growth rate of 2, and a growth period to achieve this rate of 6 hours. Assuming that none of the organisms die, this would imply that this population would double in size every 6 hours. Thus, after allowing 6 hours for growth, we would have 1000 organisms, and after 12 hours, we would have 2000 organisms. Write a program that takes these inputs and displays a prediction of the total population. An example of the program input and output is shown below: Enter the initial number of organisms: 10 Enter the rate of growth [a real number > 0]: 2 Enter the number of hours to achieve the rate of growth: 2 Enter the total hours of growth: 6 The total population is 80

i am using python

In: Computer Science