Questions
I have to complete all //to do comments for the following code: /** * A ShoppingBasket...

I have to complete all //to do comments for the following code:

/**
* A ShoppingBasket holds zero or more Products and can provide information
* about the Products. One can add Products to a ShoppingBasket during its
* lifetime, reset the ShoppingBasket, create a copy which contains Products of
* at least a certain value, and make various queries to the ShoppingBasket.
* (Thus, the number of Products that will be stored by a ShoppingBasket object
* is not yet known when the new object is created, and it may grow and shrink
* over the lifetime of a ShoppingBasket object.)
*
* @author Carsten Fuhs
*/
public class ShoppingBasket {
// TO DO instance variables
/* Constructors */
/**
* Constructs a new ShoppingBasket without any Products.
*/
public ShoppingBasket() {
// TO DO
}
/**
* Constructs a new ShoppingBasket containing the non-null Products in
* products. The products array may be modified by the caller afterwards
* without affecting this ShoppingBasket, and it will not be modified by
* this constructor.
*
* @param products must not be null; non-null elements are added to the
* constructed ShoppingBasket
*/
public ShoppingBasket(Product[] products) {
// TO DO
}
/* Modifiers */
/**
* Adds a Product e to this ShoppingBasket if e is not null; does not
* modify this ShoppingBasket otherwise. Returns true if e is not null,
* false otherwise.
*
* @param e an product to be added to this ShoppingBasket
* @return true if e is not null, false otherwise
*/
public boolean add(Product e) {
// TO DO
return false;
}
/**
* Adds all non-null Products in products to this ShoppingBasket.
*
* @param products contains the Product objects to be added to
* this ShoppingBasket; must not be null (but may contain null)
* @return true if at least one element of products is non-null;
* false otherwise
*/
public boolean addAll(Product[] products) {
// TO DO
return false;
}
/**
* Removes certain Products from this ShoppingBasket. Exactly those
* Products are kept whose price in pence is greater than or equal to the
* specified minimum price in pence.
*
* @param minProductPriceInPence the minimum price in pence for the
* Products that are kept
*/
public void keepOnlyProductsWith(long minProductPriceInPence) {
// TO DO
}
/* Accessors */
/**
* Returns the number of non-null Products in this ShoppingBasket.
*
* @return the number of non-null Products in this ShoppingBasket
*/

In: Computer Science

The initial mass of a certain species of fish is 7 million tons. The mass of...

The initial mass of a certain species of fish is 7 million tons. The mass of fish, if left alone, would increase at a rate proportional to the mass, with a proportionality constant of 2/yr initially, but over time if the population gets too high it would reach a maximum sustainable population of 50 million tons.

1. Suppose, commercial fishing removes fish mass at a constant rate of 15 million tons per year. Set up the initial value problem which determines the fish mass, F(t), in millions of tons at time t in years.

2. For your harvesting model above, what will the long term behavior of the fish population be?

In: Math

class DoubleLinkedList { public: //Implement ALL following methods. //Constructor. DoubleLinkedList(); //Copy constructor. DoubleLinkedList(const DoubleLinkedList & rhs);...

class DoubleLinkedList {

public:

//Implement ALL following methods.

//Constructor.

DoubleLinkedList();

//Copy constructor.

DoubleLinkedList(const DoubleLinkedList & rhs);

//Destructor. Clear all nodes.

~DoubleLinkedList();

// Insert function. Returns true if item is inserted,

// false if the item it a duplicate value

bool insert(int x);

// Removes the first occurrence of x from the list,

// If x is not found, the list remains unchanged.

void remove(int x);

//Assignment operator.

const DoubleLinkedList& operator=(const DoubleLinkedList & rhs);

private:

struct node{

int data;

node* next;

node* prev;

};

node* head;

node* tail;

};

For the double linked list class above, implement all of the methods.

In: Computer Science

PERIOPERATORY PROCESS OF THE PATIENT I. Answer the following premises: 1. Define the 3 phases of...

PERIOPERATORY PROCESS OF THE PATIENT

I. Answer the following premises:
1. Define the 3 phases of the perioperative process:
to. Preoperative phase
b. Intraoperative phase
c. Postoperative phase

2. Correctly identify the type of surgical intervention:
to. ____________: removes a diseased part of the body. For example, gallbladder removal (cholecystectomy).
b. ____________: repair of multiple wounds.
c. ____________ - Restores function or appearance that was lost or reduced. For example, breast implant.
d. ____________: confirm or establish a medical diagnosis; for example, Biopsy of a mass in a breast or an exploratory one.
and. ____________: replaces malfunctioning structures. For example, kidney transplant.
F. ____________: relieves or reduces pain or symptoms of the disease; does not cure. For example: placement of a gastrostomy.

In: Nursing

I want this code to be written in c++. Take a string of length n as...

I want this code to be written in c++.

Take a string of length n as an input from the user such that n>=8 and only lower-case letters (a-z) are allowed as valid string characters.

Deleting a letter from the string removes all the occurrences of that letter.

The objective is to find the longest possible string such that it is left with only two unique letters and no two consecutive characters
in a string are the same.

If there exist more than one valid longest strings, you need to print any one of those.

The solution should be implemented using pointers

Examples:

Input string: abbdacbdac - > Output string: adada

Input string: cxtdacxdacd - > Output string: cdcdcd

In: Computer Science

CS 209 Data Structure 5. Consider the Pair class covered in class: class Pair {    ...

CS 209 Data Structure

5. Consider the Pair class covered in class:

class Pair

{

    public A first;

    public B second;

    public Pair(A a, B b)

    {

        first = a;

        second = b;

    }

    public void setFirst(A a)

    {

        first = a;

    }

    public A getFirst()

    {

        return first;

    }

    public void setSecond(B b)

    {

        second = b;

    }

    public B getSecond()

    {

        return second;

    }

}

a. Create a toString() method inside the Pair class.

b. Create an equals() method inside the Pair class.

c. Create a hashCode() method inside the Pair class.

d. Create a HashSet of Pair and insert a few elements including duplicates.

Verify that the HashSet removes all the duplicates.

In: Computer Science

1. In a survey, Canadians were asked whether or not they thought that certain offences were...

1. In a survey, Canadians were asked whether or not they thought that certain offences were serious crimes. The findings of this survey are summarized in the table, where each row lists an offence and then gives the percentage of Canadians who think that the offence is a serious crime. Assume that the findings are accurate for the population of Canadians.

Answer the questions and round your answers to 4 decimal places.

Taking towels from hotels

28%

Copying software

25%

Pirating music

17%

a) What is the probability that in a random sample of seven Canadians, exactly three think that copying software is a serious crime?

In a random sample of 80 Canadians, find the following:

b) Find the probability that exactly fourteen think that pirating music is a serious crime.

c) Find the probability that between 10 and 20 (inclusive) think that taking towels from hotels is a serious crime.

NOTE: Between a and b inclusive means a ≤ x ≤ b, it does not mean a < x < b

2. The standing eye height of people is normally distributed with a mean of 1567 mm with a standard deviation of 65 mm.

a) If an art work is positioned so that it is comfortable to be viewed by people with standing eye heights greater than 1450 mm, what percentage of people will find that height comfortable? Give your answer as a percentage rounded to 2 decimal places. (For example: If your answer is 67.2576 it would be rounded to 67.26. This is just an example and not the correct answer). Do not include a percent sign. Do not include a percent sign.

b) Find the 75th percentile for the standing eye level height of people. Round your answer to 2 decimal places.

3. The cholesterol content of large chicken eggs is normally distributed with a mean of 170 milligrams and standard deviation of 18 milligrams. In 35% of the eggs, the cholesterol content is less than what value? Round your answer to 3 decimal places.

4. You are playing a wizard game where you roll a dice three times to collect magical artefacts. Each time you roll the dice, you collect an artefact according to these rules:

If you get a 2 or a 4, you collect a book of spells. If you get an odd number, you collect an enchanted coin. If get roll a 6, you collect a wand.

Let X be the number of books you collect. Find the probability distribution for X and give the following probabilities to 3 decimal places:

a) P(0): ?

b) P(1): ?

c) P(2): ?

d) P(3): ?

5. At a large second-hand electronics market, there are about 500 phone chargers for sale. It is found that the probability that a phone charger does not work is 18%.

You randomly choose fifteen phone chargers to buy for your student dorm without testing them. Answer the questions and round your answers to three decimal places where necessary.

a) Find the probability that none of the fifteen phone chargers "do not" work.

b) Find the probability that at least three phone chargers "do not" work.

c) Find the probability that between 5 and 7 phone chargers (inclusive) do not work.

d) Find the mean number of phone chargers that do not work.

NOTE: Between a and b inclusive means a ≤ x ≤ b, it does not mean a < x < b

In: Statistics and Probability

Please use Java only. Write the class TopResult, which keeps track of the best (highest numbered...

Please use Java only.

Write the class TopResult, which keeps track of the best (highest numbered or highest ordered) result it has seen so far. The class will be a generic type, so the type of results it sees depends on how it is declared.

TopResult Task:

There are a number of situations in which we want to keep track of the highest value we've seen so far - a highest score, a most recent entry, a name which is closest to the end (or the front) of a list, etc. We can imagine writing a simple class which will do this: a class which will let us enter new results one by one, and at any point will let us stop and ask for the highest value.

So far, so good, right? But what if we have a number of different applications for this sort of class - for example, we want to find the top (integer) score on a test, or the highest (decimal) temperature reading, or the GUI window which is closest to the top, etc. Subclassing isn't quite the way to go here, because a TopResult which holds Integers isn't an instance of a TopResult which holds Doubles, and vice versa. But simply writing a class for every possible type we may need may seem like overkill, since the structure of the code is essentially the same from class to class.

In situations such as these, generics come to our rescue. When we define a generic class, the data type we use is essentially represented as a wildcard - a generic type parameter, which we can call T for instance. We write the class assuming that we have a type T in mind, with the idea that we will fill in the type once we know what it is. This is how an ArrayList is implemented, for example. It is a dynamic array of some generic type T, and the exact type is decided (specialized) when we declare the ArrayList variable, for example ArrayList<String> a. If we write our entire class in terms of this unkown type parameter, we will be able to simply name the type later when we want to use it.

In this exercise, we will write the class TopResult. It will have a generic type parameter (you can call it T or something else). Type T must be a Comparable type (thus, the full generic type parameter would be <T extends Comparable<T>>).

A Comparable is an interface which is implemented by classes such as Integer, Double, Character, and String, which allow two members of the same type to be compared to one another to see which is larger. The interface has one method, compareTo, which returns a negative, zero, or positive result indicating whether the object is less than, equal to, or greater than the object it is being compared against:

> Integer three = 3, four = 4;
> three.compareTo(four)
-1
> four.compareTo(three)
1
> four.compareTo(four)
0

The TopResult task should implement the following public methods:

  • TopResult, a default constructor. Initially there should be no top result since no results have been seen yet.
  • newResult, which takes an object of type T, representing a new result, as a parameter, but does not return anything. This method will check whether the new result is better than the current top result, and if so, replace it, otherwise it will ignore it. If there is currently no top result (because no results had been seen yet), then the current result automatically becomes the top result.
  • getTopResult, which does not take any parameters but returns the current top result. If there is currently no top result (because no results have been seen yet), then this method should return null.
  • toString, which will return the toString value of the current top result, or a null if there have been no results yet.

The following shows an example use of this class:

> TopResult<Integer> tr = new TopResult<Integer>();
> tr.getTopResult() // no results seen yet, should be null
null
> tr.newResult(7);
> tr.getTopResult()
7
> tr.newResult(3);
> tr.getTopResult()
7
> tr.newResult(4);
> tr.getTopResult()
7
> tr.newResult(9);
> tr.getTopResult()
9
> tr.newResult(20);
> tr.getTopResult()
20
> tr.toString() // this will print the toString() of the current top result
"20"

Please make sure that it passes the following: https://repl.it/@micky123/SweetEmotionalExtraction

Please be sure that the work is your own, not a duplicate of somebody else's. Thank you.

In: Computer Science

Question 1 If the theoretical value of a quantity is 3.142, and the calculated value is...

Question 1

If the theoretical value of a quantity is 3.142, and the calculated value is 3.146, what is the percent error? (closest value)

Group of answer choices

0.1 %

0.2%

0.3%

Question 2

In an experiment to measure the value of pi, the following results are obtained for pi:

3.14                    3.13                 3.24                 3.06                 3.02                                        

If the correct value is 3.14159, calculate the Percent Error (closest value)

Group of answer choices

0.3%

0.7%

1 %

2%

Question 3

What determines the number of significant figures used in reporting measured values?

Group of answer choices

The accuracy of the calculations

The accuracy of the equipment

Question 4

Calculate, to the correct number of significant figures:

21.414 + 15.231 + 17.24 + 5.01

Group of answer choices

58.90

58.9

58.895

58.89

Question 5

If the time period for a certain pendulum while standing in the Lab. on Earth is T second, will the time period be longer or shorter if It is taken to the Moon:

Group of answer choices

Longer

Shorter

Question 6

If the time period for a certain pendulum while standing in the Lab. on Earth is T second, will the time period be longer or shorter if it is taken to the planet Jupiter

Group of answer choices

Longer

Shorter

Question 7

If the time period for a certain pendulum while standing in the Lab. on Earth is T second, will the time period be longer or shorter if it is in an elevator that is accelerating upwards

Group of answer choices

Longer

Shorter

Question 8

For a vertically oscillating spring-mass system, should the time period depend on the amplitude of oscillation?

Group of answer choices

Yes

No

Question 9

What error can you expect if you use the stopwatch to measure the time for only 10 oscillations instead of 50 as mentioned in the manual?

Group of answer choices

The time period becomes smaller

Time period remains same, but the error in its measurement increases.

The time period remains same, and the error in its measurement decreases.

The time period becomes longer

In: Physics

Complete the following program:LinkedQueue.zip package jsjf; /** * Represents a node in a linked list. */...

Complete the following program:LinkedQueue.zip

package jsjf;

/**
* Represents a node in a linked list.
*/
public class LinearNode<T>
{
   private LinearNode<T> next;
   private T element;

   /**
   * Creates an empty node.
   */
   public LinearNode()
   {
       next = null;
       element = null;
   }

   /**
   * Creates a node storing the specified element.
   * @param elem element to be stored
   */
   public LinearNode(T elem)
   {
       next = null;
       element = elem;
   }

   /**
   * Returns the node that follows this one.
   * @return reference to next node
   */
   public LinearNode<T> getNext()
   {
       return next;
   }

   /**
   * Sets the node that follows this one.
   * @param node node to follow this one
   */
   public void setNext(LinearNode<T> node)
   {
       next = node;
   }

   /**
   * Returns the element stored in this node.
   * @return element stored at the node
   */
   public T getElement()
   {
       return element;
   }

   /**
   * Sets the element stored in this node.
   * @param elem element to be stored at this node
   */
   public void setElement(T elem)
   {
       element = elem;
   }
}

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

package jsjf;

import jsjf.exceptions.*;

/**
* LinkedQueue represents a linked implementation of a queue.
*/
public class LinkedQueue<T> implements QueueADT<T>
{
   private int count;
   private LinearNode<T> head, tail;

   /**
   * Creates an empty queue.
   */
   public LinkedQueue()
   {
       count = 0;
       head = tail = null;
   }

   /**
   * Adds the specified element to the tail of this queue.
   * @param element the element to be added to the tail of the queue
   */
   public void enqueue(T element)
   {
       LinearNode<T> node = new LinearNode<T>(element);

       if (isEmpty())
           head = node;
       else
           tail.setNext(node);

       tail = node;
       count++;
   }

   /**
   * Removes the element at the head of this queue and returns a
   * reference to it.
   * @return the element at the head of this queue
   * @throws EmptyCollectionException if the queue is empty
   */
   public T dequeue() throws EmptyCollectionException
   {
       if (isEmpty())
           throw new EmptyCollectionException("queue");

       T result = head.getElement();
       head = head.getNext();
       count--;

       if (isEmpty())
           tail = null;

       return result;
   }

   /**
   * Returns a reference to the element at the head of this queue.
   * The element is not removed from the queue.
   * @return a reference to the first element in this queue
   * @throws EmptyCollectionsException if the queue is empty
   */
   public T first() throws EmptyCollectionException
   {
       // To be completed as a Programming Project
      
       return null; // temp
   }

   /**
   * Returns true if this queue is empty and false otherwise.
   * @return true if this queue is empty
   */
   public boolean isEmpty()
   {
       // To be completed as a Programming Project
      
       return true; // temp
   }

   /**
   * Returns the number of elements currently in this queue.
   * @return the number of elements in the queue
   */
   public int size()
   {
       // To be completed as a Programming Project
      
       return 0; // temp
   }

   /**
   * Returns a string representation of this queue.
   * @return the string representation of the queue
   */
   public String toString()
   {
       // To be completed as a Programming Project
      
       return ""; // temp
   }
}

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

package jsjf;

/**
* QueueADT defines the interface to a queue collection.
*/
public interface QueueADT<T>
{
   /**
   * Adds one element to the rear of this queue.
   * @param element the element to be added to the rear of the queue
   */
   public void enqueue(T element);

   /**
   * Removes and returns the element at the front of this queue.
   * @return the element at the front of the queue
   */
   public T dequeue();

   /**
   * Returns without removing the element at the front of this queue.
   * @return the first element in the queue
   */
   public T first();

   /**
   * Returns true if this queue contains no elements.
   * @return true if this queue is empty
   */
   public boolean isEmpty();

   /**
   * Returns the number of elements in this queue.
   * @return the integer representation of the size of the queue
   */
   public int size();

   /**
   * Returns a string representation of this queue.
   * @return the string representation of the queue
   */
   public String toString();
}

In: Computer Science