Questions
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

in C language only. Write a program called gamecards.c that has a card game logic by...

in C language only.

Write a program called gamecards.c that has a card game logic by comparing the cards from 4 people and calculating which player has the best card.

1. Every card must be represented by exactly two chars
representing a rank and a suit.

ranks: '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'. ('T' = 10)

Suits: 'H', 'D', 'S', 'C'.

7D represents the “7 of Diamond” etc..


2. Write a function called isRank(char c) which
calculate if the given character is one of the ranks. It would return a char with a value of 1 if the character is a valid rank and 0 if not.

Write a function called isSuit(char c) which calculate if the given character is one of the suits. It should return a char with a value of 1 if the character is a valid suit and 0 if not.
(Lowercase are not valid for both functions)

In: Computer Science

Explian interpolation: bilinear interpolation, subject is digital image processing.

Explian interpolation: bilinear interpolation, subject is digital image processing.

In: Computer Science