Questions
Question: In a package named "oop" create a Scala class named "Team" and a Scala object...

Question: In a package named "oop" create a Scala class named "Team" and a Scala object named "Referee". Team will have:

• State values of type Int representing the strength of the team's offense and defense with a constructor to set these values. The parameters for the constructor should be offense then defense

• A third state variable named "score" of type Int that is not in the constructor, is declared as a var, and is initialized to 0 Referee will have:

• A method named "playGame" that takes two Team objects as parameters and return type Unit. This method will alter the state of each input Team by setting their scores equal to their offense minus the other Team's defense. If a Team's offense is less than the other Team's defense their score should be 0 (no negative scores)

• A method named "declareWinner" that takes two Teams as parameters and returns the Team with the higher score. If both Teams have the same score, return a new Team object with offense and defense both set to 0

In: Computer Science

In this assignment, you will write a class that implements a contact book entry. For example,...

In this assignment, you will write a class that implements a contact book entry. For example, my iPhone (and pretty much any smartphone) has a contacts list app that allows you to store information about your friends, colleagues, and businesses. In later assignments, you will have to implement this type of app (as a command line program, of course.) For now, you will just have to implement the building blocks for this app, namely, the Contact class.
Your Contact class should have the following private data:
• The first name of the person
• The last name of the person •The phone number of the person • The street address of the person • The city of the person
• The state of the person
The Contact class should implement the Comparable interface. More on this later.
Of course, you may implement private helper methods if it helps your implementation.
Your class should have the following public methods:
• A constructor that initializes all the fields with information.
• A constructor that initializes only the name and phone number.
• accessor (getter) methods for all of the data members.
• an update method that allows the user to change all information. (They must change all of it).
• An overridden equals() method that can tell if one Contact is the same as another. It should have the method signature:
public boolean equals(Object obj);
We will define one Contact as being the same as another contact if the first and last names both match. (Be careful! The parameter may not be a bona fide Contact!)
• An overridden toString() method that creates a printable representation for a Contact object.
  
It should have the method signature:
public String toString();
The String should be created in the following form:
<First name> <last name> Phone number: <phone number> <street address>
<city> , <state>
For example my contact info would look like:
john Doe Phone number: (111) 111-1111
2900 XYZ Avenue
city, state
• A comparison method that looks like this:
public int compareTo(Contact another);
We will define this method in the following way:
If the last name of “another” is lexicographically first, return a positive
number.
If the last name of “another” is lexicographically second, return a negative
number.
If the last names are the same and the first names are also the same, return 0. If the last names are the same and the first names are different, use the first
names to determine the order.
You must also declare the fact that Contact implements the Comparable interface.
You must also write a main program that tests each of these functions and
shows me that you understand how to use the Contact class in a program.
You can choose to write this main program as a stand alone class that sits in the same directory as the Contact class, or you can just make the main program the main program of the Contact class itself.

In: Computer Science

Create a method that takes a HashMap<Integer, Integer> and returns the sum of the keys of...

Create a method that takes a HashMap<Integer, Integer> and returns the sum of the keys of the HashMap.

In: Computer Science

Explain Interpolation: Reverse neighbor interpolation, subject is digital image processing

Explain Interpolation: Reverse neighbor interpolation, subject is digital image processing

In: Computer Science

I am having trouble fixing my build errors. The compiler I am using is Visual Studio.Thanks....

I am having trouble fixing my build errors. The compiler I am using is Visual Studio.Thanks.

#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

/*
* structure to store employee details
* employee details are stored as linked list
*/
struct Employee
{
private:

   string full_name; //full name
   double net_income; //income

public:
   struct Employee *next; //pointing to the next employee details in the list

                       /*
                       * create new employee node
                       */
   Employee(string full_name, double net_income)
   {
       this->full_name = full_name;
       this->net_income = net_income;
       this->next = NULL;
   }

   /*
   * display the details of this employee
   */
   void displayDetails()
   {
       cout << "\tFull name : " << full_name << endl;
       cout << "\tDaily salary: " << net_income << endl << endl;
   }
};

/*
* Implementation of Queue
*/
class EmployeeQueue
{
   struct Employee *front = NULL, *rear = NULL; // front and rear pointers of queue

public:
   /*
   * inset a new employee details into queue
   * this function take argument as a pointer to employee struct
   */
   void enqueue(struct Employee *newEmployee)
   {
       if (rear == NULL)
       {
           /*
           * empty wueue
           */
           rear = newEmployee;
           front = newEmployee;
       }
       else
       {
           /*
           * not empty
           * inseting new details at rear
           */
           rear->next = newEmployee;
           rear = newEmployee;
       }
   }

   /*
   * remove employee who is in front of the queue
   * this function return a pointer to employee struct
   */
   Employee* dequeue()
   {
       if (front == NULL)
       {
           /*
           * empty queue
           */
           return NULL;
       }

       /*
       * details of employee who is in front
       */
       struct Employee *leavingEmployee = front;

       front = front->next;

       if (front == NULL)
           rear = NULL;

       return leavingEmployee;
   }
};

int main()
{
   Employee * employee; //pointer of employee structure
   EmployeeQueue *queue = new EmployeeQueue(); //pointer of employee queue

   int ch = 0;
   string first_name;
   string last_name;
   string full_name;
   double work_hours;
   double hourly_rate;
   double tax_rate;
   double gross_salary;
   double net_salary;

   /*
   * iterate user inputs until exit command
   */

   while (ch != 3)
   {
       /*
       * displaying main menu
       */
       cout << endl << "1. Enter an employee information" << endl;
       cout << "2. Display information of employee who is leaving the work" << endl;
       cout << "3. Exit program" << endl;
       cout << "Enter your choice: ";
       cin >> ch; //getting choice

               /*
               * processing user choice
               */
   }

   switch (ch)
   {
   case 1:
   {   /*
       * choice to add new employee
       *
       * getting input of employee details
       */
       cout << "\tEnter first name of employee : ";
       cin >> first_name;
       cout << "\tEnter the last name of the employee : ";
       cin >> last_name;
       cout << "\tEnter working hours of the employee : ";
       cin >> work_hours;
       cout << "\tEnter the hourly working rate of the employee: ";
       cin >> hourly_rate;
       cout << "\tEnter the tax rate (%) of the employee : ";
       cin >> tax_rate;

       /*
       * finding full name
       *
       * full name = first name + last name
       */
       full_name = first_name + " " + last_name;

       /*
       * calculating gross salary
       *
       * gross salary = working hours * hourly rate
       */
       gross_salary = (work_hours * hourly_rate);

       /*
       * calculating net salary
       *
       * net salary = gross salary - (gross salary * (tax rate / 100)
       */
       net_salary = gross_salary - (gross_salary * tax_rate / 100.0);

       /*
       * creating new employee structure
       */
       employee = new Employee(full_name, net_salary);

       /*
       * inserting new employee details into queue
       */

       queue->enqueue(employee);
   }
   break;
   {case 2:
       /*
       * choice to display details
       */
       /*
       * getting details of employee who is leaving
       */
       employee = queue->dequeue();
   }
   if (employee != NULL)
   {
       /*
       * if not null displaying details
       */
       cout << "\tDetails of employee who is leaving:" << endl;
       employee->displayDetails();
   }
   else
   {
       /*
       * queue is empty
       */
       cout << "Queue is empty." << endl;
   }
   break;
   {   case 3:
       /*
       * choice to exit
       *
       * free all memories allocated dynamically
       */

   Employee * employee = NULL;
   free(employee);
   free(queue);
   break;
  
   default:
       /*
       * invalid choice
       */
       cout << "Invalid choice. Please enter it again." << endl;
  
   }
   }
   system("pause");
   return 0;

};


In: Computer Science

SalaryCalculator in Java. The SalaryCalculator class should have instance variables of: an employee's name, reportID that...

SalaryCalculator in Java. The SalaryCalculator class should have instance variables of:

an employee's name, reportID that is unique and increments by 10, and an hourly wage.

There should also be some constructors and mutators, and accessor methods.

In: Computer Science

Which location determines the jurisdiction of a breach of personally identifiable information (PII)? Where the PII...

Which location determines the jurisdiction of a breach of personally identifiable information (PII)?

Where the PII breach occurred

Where the individuals with compromised PII reside

Where the PII was processed

Where the compromised PII was stored

In: Computer Science

The following question is based upon the BIRD relation below, which lists information about the birds...

The following question is based upon the BIRD relation below, which lists information about the birds of the USA . You can assume the data is representative. Note that scientific names are generally used worldwide for plants and animals to eliminate ambiguity, as common names can vary between countries. You have been asked to design a relational database based on this design. You know that there are problems with the current design and that it will need to be modified in order to work effectively. Answer the following questions.

a. What is the candidate key (or keys) of the relation, as it currently exists? What normal form is the relation in? Explain your reasoning.

b. Explain the problems with the existing design, in terms of the potential modification anomalies that it might exhibit.

c. Convert the relation to a set of relations in at least Third Normal Form (3NF). You only need to show the schema, not the data. Do not create any new attributes: work with the ones in the table. Give each of your new relations an appropriate name. Show all primary keys and foreign keys.

d. Explain how your new design addresses the problems you identified in (b). Also demonstrate that your set of relations has the dependency preserving and lossless join properties.

HABITAT GENUS SPECIES ORDER FAMILY FAMILY NAME COMMON NAME FOOD DISTRIBUTION CONSERVATION
desert melanerpes uropygialis Piciformes Picidae Woodpeckers Gila Woodpecker Omnivore Southwestern US Low concern
Forests Buteo platypterus Accipitriformes Accipitridae Hawks, Eagles and Kites Broad-winged Hawk Small animals Eastern US Low concern
Lakes and ponds Pandion haliaetus Accipitriformes Pandionidae Osprey Osprey Fish Northern US Low concern
Lakes and ponds Aix sponsa Anseriformes Anatidae Ducks, Geese and Waterfowl Wood Duck Insects Eastern US low concern
Lakes and ponds Aix sponsa Anseriformes Anatidae Ducks, Geese and Waterfowl Wood Duck Insects Northwest US Low concern
Lakes and ponds Gavia pacifica Gaviiformes Gaviidae Loons Pacific Loon Fish Pacific Coast Low concern
Lakes and ponds Pelecanus erythrorhynchos Pelecaniformes Pelecanidae Pelicans American White Pelican fish Central US low concern
Lakes and ponds Pelecanus erythrorhynchos Pelecaniformes Pelecanidae Pelicans American White Pelican Fish Southern Coast Low concern
Marshes Anser canagicus Anseriformes Anatidae Ducks, Geese and Waterfowl Emperor Goose Plants Northwest Coast Restricted range
Marshes Eudocimus albus Pelecaniformes Threskiornithidae Ibises and Spoonbills White Ibis Aquatic invertebrates Southeast US Low concern
Oceans Larus occidentalis Charadriiformes Laridae Gulls, Terns, and Skimmers Western Gull Fish Pacific Coast Low concern

Please help ^_^. My brain is fried, any help is appreciated!

In: Computer Science

How do I get the following code to accept a float input, while also fixing the...

How do I get the following code to accept a float input, while also fixing the syntax errors in the code because I can't figure out what is wrong with it.

def chemical_strength(pH):
if 0<pH>14:
if pH <= 7:
if pH = 7:
ans = str("neutral")
else: # ph < 7
if 0<pH>=1:
ans = str("very strong acid")
else: # 1<pH>7
if 1<pH>4:
ans = str("strong acid")
else: # 4=<ph>7
if pH = 4:
ans = str("plain acid")
else: # 4<pH>7
if 4<pH>6:
ans = str("weak acid")
else: # 6=<pH>7
ans = str("very weak acid")
else pH >= 7:
if pH = 7:
ans = str("neutral")
else: # ph > 7
if 7<pH>=8:
ans = str("very weak base")
else: # 8<pH>14
if 8<pH>10:
ans = str("weak base")
else: # 10=<pH>14
if pH = 10:
ans = str("plain base")
else: # 10<pH>14
if 10<pH>13:
ans = str("strong base")
else: # 13=<pH>14
ans = str("very strong base")
else:
ans = str("bad measurement")
return ans

In: Computer Science

The Golomb's sequence is G(n) = 1 + G(n - G(G(n - 1))) For what n...

The Golomb's sequence is G(n) = 1 + G(n - G(G(n - 1)))

For what n value (approximately) does your computer stop producing output? Why is this?  

The following is my code, but I don't know what would be the max value for n, since my computer stuck at 80

#include <iostream>

using namespace std;

int golombSequence(int);

int golombSequence(int max){

if(max == 1){

return 1;

}

else{

return 1 + golombSequence(max - golombSequence(golombSequence(max-1)));

}

}

int main(int argc, const char * argv[]) {

// int n = 90;

// for(int i = 1; i<=n; i++){

// cout<<i<<": "<<golombSequence(i)<<endl;

// }

// return 0;

}

In: Computer Science

Using the R code below, calculate daily log returns and assign the name ‘returnlogs’ library(quantmod) getSymbols("MSFT",...

Using the R code below, calculate daily log returns and assign the name ‘returnlogs’

library(quantmod) getSymbols("MSFT", src = "yahoo", from='2017-01-03', to='2018-12-31')

b) MSFTAduestedj <- MSFT$MSFT.Adjusted

In: Computer Science

What tasks and deliverables are needed to implement "User Domain" risk mitigation recommendations?

What tasks and deliverables are needed to implement "User Domain" risk mitigation recommendations?

In: Computer Science

Provide code and assertion statements for the pre/post-conditions. (To execute the assertion code, the java.exe requires...

Provide code and assertion statements for the pre/post-conditions. (To execute the assertion code, the java.exe requires the option -ea for the VM).

// ***  MyArrayList is limited to 100 elements.  ***
public class MyArrayList<E> extends ArrayList<E> {

    public MyArrayList() {
        // assert postcondition
    }

    @Override
    public int size() {
        // assert postcondition
        // code
    }

    // Insert e as a new first element to mal
    public void insertFirst(E e) {
        // assert precondition
        // code
        // assert postcondition
    }

    // Insert e as a new last element
    public void insertLast(E e) {
        // assert precondition
        // code
        // assert postcondition
    }

    // Delete my first element
    public void deleteFirst() {
        // assert precondition
        // code
        // assert postcondition
    }

    // Delete my last element
    public void deleteLast() {
        // assert precondition
        // code
        // assert postcondition
    }

    public void show() {
        for (E e : this) {
            System.out.println(e);
        }
    }
}

public class Student {
     // code
}

public class MyProg {
    public static void main(String[] args) {
        MyArrayList<Student> mal = new MyArrayList<>();
        mal.insertFirst(new Student(1, "John"));
        mal.insertFirst(new Student(2, "Mary"));
        mal.insertLast(new Student(3, "Mike"));
        mal.show();
        mal.deleteLast();
        mal.show();       
        mal.deleteFirst();
        mal.show();

    }
  }

// ------------------- EXPECTED OUTPUT --------------------- //

The following is the execution output if all assertions are valid and passed:

2, Mary

1, John

3, Mike

2, Mary

1, John

1, John

In: Computer Science

At the onset of this course, we discussed converting data into information, or knowledge. In your...

At the onset of this course, we discussed converting data into information, or knowledge. In your own words, describe that process. Why is it important?

In: Computer Science

What is the difference between a process and a thread? What prevents complete thread independence? Give...

  • What is the difference between a process and a thread?
  • What prevents complete thread independence? Give one specific example of a dependency.
  • What are the advantages/disadvantages of designing a concurrent program using threads versus events?

In: Computer Science