Questions
Imagine you are writing a program to manage a shopping list. Each shopping list item is...

Imagine you are writing a program to manage a shopping list. Each shopping list item is represented by a string stored in a container. Your design requires a print function that prints out the contents of the shopping list. Using a vector to hold the shopping list items, write a print function to print out the contents of a vector of strings. Test your print function with a main program that does the following:

Create an empty vector.
Append the items, "eggs," "milk," "sugar," "chocolate," and "flour" to the list. Print it.
Remove the last element from the vector. Print it.
Append the item, "coffee" to the vector. Print it.
Write a loop that searches for any item whether it is present in the vector or not.
Write a loop that searches for the item, "milk," and then remove it from the vector. (You are permitted to reorder the vector to accomplish the removal, if you want.) Print the vector.

Input:

sugar

Output:

eggs milk sugar chocolate flour

eggs milk sugar chocolate

eggs milk sugar chocolate coffee

present

eggs sugar chocolate coffee

In: Computer Science

A: Prepare a balance sheet at May 31. (List Assets in order of liquidity. List Property,...

A: Prepare a balance sheet at May 31. (List Assets in order of liquidity. List Property, plant and equipment in order of land, buildings and equipment. Round answers to 0 decimal places, e.g. 5,275.)

B: Prepare an income statement for the month of May 31. (Round answers to 0 decimal places, e.g. 5,275.)

The Skyline Motel opened for business on May 1, 2017. Its trial balance before adjustment on May 31 is as follows.

SKYLINE MOTEL
Trial Balance
May 31, 2017

Account Number Debit Credit
101 Cash $ 3,600
126 Supplies 2,050
130 Prepaid Insurance 3,000
140 Land 12,000
141 Buildings 62,400
149 Equipment 15,400
201 Accounts Payable $ 11,700
208 Unearned Rent Revenue 3,000
275 Mortgage Payable 40,000
311 Common Stock 36,000
429 Rent Revenue 12,500
610 Advertising Expense 600
726 Salaries and Wages Expense 3,300
732 Utilities Expense 850
$103,200 $103,200


In addition to those accounts listed on the trial balance, the chart of accounts for Skyline Motel also contains the following accounts and account numbers: No. 142 Accumulated Depreciation—Buildings, No. 150 Accumulated Depreciation—Equipment, No. 212 Salaries and Wages Payable, No. 230 Interest Payable, No. 619 Depreciation Expense, No. 631 Supplies Expense, No. 718 Interest Expense, and No. 722 Insurance Expense.

Other data:

1. Prepaid insurance is a 1-year policy starting May 1, 2017.
2. A count of supplies shows $800 of unused supplies on May 31.
3. Annual depreciation is $3,120 on the buildings and $1,536 on equipment.
4. The mortgage interest rate is 12%. (The mortgage was taken out on May 1.)
5. Two-thirds of the unearned rent revenue has been earned.
6. Salaries of $800 are accrued and unpaid at May 31.

In: Accounting

List the ways that we evaluate (test methods) platelets in the lab. Just a simple list...

List the ways that we evaluate (test methods) platelets in the lab. Just a simple list at this point.

In: Biology

List the two types of sources of​ funds; list first the type having the stronger claim...

List the two types of sources of​ funds; list first the type having the stronger claim on an​ entity's assets:



Stronger claim

Lesser claim

In: Accounting

Use Scheme Language Write a Scheme function that takes a list and returns a list identical...

Use Scheme Language

Write a Scheme function that takes a list and returns a list identical to the parameter except the third element has been deleted. For example, (deleteitem '(a b c d e)) returns ‘(a b d e) ; (deleteitem '(a b (c d) e)) returns ‘(a b e).

In: Computer Science

A: Prepare a balance sheet at May 31. (List Assets in order of liquidity. List Property,...

A: Prepare a balance sheet at May 31. (List Assets in order of liquidity. List Property, plant and equipment in order of land, buildings and equipment. Round answers to 0 decimal places, e.g. 5,275.)

B: Prepare an income statement for the month of May 31. (Round answers to 0 decimal places, e.g. 5,275.)

The Skyline Motel opened for business on May 1, 2017. Its trial balance before adjustment on May 31 is as follows.

SKYLINE MOTEL
Trial Balance
May 31, 2017

Account Number Debit Credit
101 Cash $ 3,600
126 Supplies 2,050
130 Prepaid Insurance 3,000
140 Land 12,000
141 Buildings 62,400
149 Equipment 15,400
201 Accounts Payable $ 11,700
208 Unearned Rent Revenue 3,000
275 Mortgage Payable 40,000
311 Common Stock 36,000
429 Rent Revenue 12,500
610 Advertising Expense 600
726 Salaries and Wages Expense 3,300
732 Utilities Expense 850
$103,200 $103,200


In addition to those accounts listed on the trial balance, the chart of accounts for Skyline Motel also contains the following accounts and account numbers: No. 142 Accumulated Depreciation—Buildings, No. 150 Accumulated Depreciation—Equipment, No. 212 Salaries and Wages Payable, No. 230 Interest Payable, No. 619 Depreciation Expense, No. 631 Supplies Expense, No. 718 Interest Expense, and No. 722 Insurance Expense.

Other data:

1. Prepaid insurance is a 1-year policy starting May 1, 2017.
2. A count of supplies shows $800 of unused supplies on May 31.
3. Annual depreciation is $3,120 on the buildings and $1,536 on equipment.
4. The mortgage interest rate is 12%. (The mortgage was taken out on May 1.)
5. Two-thirds of the unearned rent revenue has been earned.
6. Salaries of $800 are accrued and unpaid at May 31.

In: Accounting

Generate a list of the characteristics of ineffective speakers you have seen. Next, generate a list...

Generate a list of the characteristics of ineffective speakers you have seen. Next, generate a list of the characteristics of the effective speakers you have seen. What three qualities do you believe are most important to be a successful speaker? Explain.

In: Nursing

Please use C++ and linked list to solve this problem Linked list 1 -> 3 ->...

Please use C++ and linked list to solve this problem


Linked list 1 -> 3 -> 4 -> 5-> 6 ->7

replaceNode( 5 , 6) // Replace 5 with 6

    result 1 -> 3 -> 4 -> 6 -> 6 ->7

Base code

#include <iostream>

using namespace std;

class Node {
public:
    int data;
    Node *next;

    Node(int da = 0, Node *p = NULL) {
        this->data = da;
        this->next = p;
    }
};

class LinkedList {
private:
    Node *head, *tail;
    int position;
public:
    LinkedList() { head = tail = NULL; };

    ~LinkedList() {
        delete head;
        delete tail;
    };

    void print();
    void Insert(int da = 0);


}


void LinkedList::Insert(int da) {
    if (head == NULL) {
        head = tail = new Node(da);
        head->next = NULL;
        tail->next = NULL;
    } else {
        Node *p = new Node(da);
        tail->next = p;
        tail = p;
        tail->next = NULL;

}

}


int main() {
    cout << "Hello World!" << endl;
    LinkedList l1;
    l1.Insert(1);
    l1.Insert(3);
    l1.Insert(4);
    l1.Insert(5);

    l1.Insert(6);

    l1.Insert(7);


    l1.print();

   l1.replaceNode( 5 , 6)

   l1.print();
    cout << "The End!" << endl;
    return 0;
}

    }

}

In: Computer Science

3.1 Write code that creates an ArrayList object named list and fills list with these numbers...

3.1 Write code that creates an ArrayList object named list and fills list with these numbers (using one or a pair of for or while loops): 0 1 2 3 4 0 1 2 3 4

3.2 Consider the ArrayList object named list containing these Integers: list = { 1, 2, 3, 4, 5, 4, 3, 2, 1, 0 } What are the contents of list after this loop completes? for (int i = 1; i < 10; ++i) { list.set(i, list.get(i) + list.get(i-1)); }

3.3 Write an enhanced for loop that counts how many numbers in an ArrayList object named list are negative. Print the count after the loop terminates.

3.4 Write a method named arrayListSum() that has one parameter pList which is an object of the class ArrayList . The method shall return the sum of the elements of pList.

3.5 Write a method named named arrayListCreate() that has two int parameters pLen and pInitValue. The method shall create and return a new ArrayList object which has exactly pLen elements. Each element shall be initialized to pInitValue.

3.6 Write a void method named insertName() that has two input parameters: (1) pList which is an object of ArrayList link in course schedule where each element of pList is a person's name; and (2) a String object named pName. Assume the names in pList are sorted into ascending order. The method shall insert pName into pList such that the sort order is maintained.

3.7 Write a void method named arrayListRemove() which has two parameters: pList is an object of the ArrayList class and pValue is an int. The method shall remove all elements from pList that are equal to pValue.

In: Computer Science

Java The List ADT has an interface and a linked list implementation whose source code is...

Java

The List ADT has an interface and a linked list implementation whose source code is given at the bottom of this programming lab description. You are to modify the List ADT's source code by adding the method corresponding to the following UML:

+hasRepeats() : boolean

hasRepeats() returns true if the list has a value that occurs more than once in the list

hasRepeats() returns false if no value in the list occurs more than once in the list

For example, if a List ADT object is created and has the following values inserted into it:

1, 1, 3, 4, 5

hasRepeats() would return true because the value 1 occurs more than once in the list

but if a List ADT object is created and has the following values inserted into it:

1, 2, 3, 4, 5

hasRepeats() would return false because no value in the list occurs more than once in the list.

The List ADT has methods that may be useful in writing hasRepeats(). You may call any existing methods of the List ADT inside hasRepeats().

Once you have modified the List ADT to have the hasRepeats() method, write a Java Client program that makes a List ADT object, takes integers as input from a user, stores the integers in the List ADT object, and uses the hasRepeats() method to display whether the List ADT object contains repeated values.

The Client program will have a main() method and is the program that is run at the command line. You may give your Client program any name you like. The Client program should perform a loop, ask for input, and display output in the following way.

Input a list of integers: 1 1 3 4 5
The list has repeated values.
Do you want to continue (y/n):  y
  
Input a list of integers: 1 2 10 20 100 200
The list does not have repeated values.
Do you want to continue (y/n):  y
 
Input a list of integers:
The list does not have repeated values.
Do you want to continue (y/n):  y

Input a list of integers: 2
The list does not have repeated values.
Do you want to continue (y/n):  

public interface ListInterface
{
   public void add(T newEntry);
   public void add(int newPosition, T newEntry);
   public T remove(int givenPosition);
   public void clear();
   public T replace(int givenPosition, T newEntry);
   public T getEntry(int givenPosition);
   public T[] toArray();
   public boolean contains(T anEntry);
   public int getLength();
   public boolean isEmpty();
}

public class LList implements ListInterface
{
   private Node firstNode; // reference to the first node of chain
   private int numberOfEntries;
   public LList ()
   {
       initializeDataFields();
   }// end default constructor
  
   public void clear()
   {
       initializeDataFields();
   }//end clear
  
   public void add(T newEntry) // outOfMemoryError possible
   {
       Node newNode = new Node(newEntry);
       if (isEmpty())
           firstNode = newNode;
       else                    // add to end of nonempty link list
       {
           Node lastNode = getNodeAt(numberOfEntries);
           lastNode.setNextNode(newNode);   // Make last node reference new node
          
       }// end if
       numberOfEntries++;
   }// end add
  
   public void add(int givenPosition, T newEntry) // outOfMemoryError possible
   {
       if ((givenPosition >= 1) && (givenPosition <= numberOfEntries +1))
       {
           Node newNode = new Node(newEntry);
          
           if(givenPosition == 1)       // case 1
           {
               newNode.setNextNode(firstNode);
               firstNode = newNode;
           }
           else                        // case 2
           {                           // and givenPosition > 1
               Node nodeBefore = getNodeAt(givenPosition -1);
               Node nodeAfter = nodeBefore.getNextNode();
               newNode.setNextNode(nodeAfter);
               nodeBefore.setNextNode(newNode);
           }// end if
           numberOfEntries ++;
       }
       else
           throw new IndexOutOfBoundsException("illegal position given to add operation");
   }// end add
  
   public T remove(int givenPosition)
   {
       T result = null;                   //return value
       if ((givenPosition >= 1) && (givenPosition <= numberOfEntries))
       {   // assertion: !isEmpty
           if(givenPosition == 1)
           {
               result = firstNode.getData();
               firstNode = firstNode.getNextNode();
           }
           else
           {
               Node nodeBefore = getNodeAt(givenPosition -1);
               Node nodeToRemove = nodeBefore.getNextNode();
               result = nodeToRemove.getData();
               Node nodeAfter = nodeToRemove.getNextNode();
               nodeBefore.setNextNode(nodeAfter);
           }
           numberOfEntries--;
           return result;
       }
       else
           throw new IndexOutOfBoundsException("illegal position given to remove operation.");
   }
  
   public T replace(int givenPosition, T newEntry)
   {
       if ((givenPosition >= 1) && (givenPosition <= numberOfEntries)) {
           Node desiredNode = getNodeAt(givenPosition);
           T originalEntry = desiredNode.getData();
           desiredNode.setData(newEntry);
           return originalEntry;
       }
       else
           throw new IndexOutOfBoundsException("illegal position given to replace operation.");
   }
   public T getEntry(int givenPosition)
   {
       if ((givenPosition >= 1) && (givenPosition <= numberOfEntries)) {
           return getNodeAt(givenPosition).getData();
       }
       else
           throw new IndexOutOfBoundsException("illegal position given to getEntry operation.");
   }
   public T[] toArray()
   {
       T[] result = (T[])new Object[numberOfEntries];
       int index = 0;
       Node currentNode = firstNode;
       while ((index < numberOfEntries) && (currentNode != null)) {
           result[index] = currentNode.getData();
           currentNode = currentNode.getNextNode();
           index ++;
       }
       return result;
   }
  
  
  
  
   public boolean contain(T anEntry)
   {
       boolean found = false;
       Node currentNode = firstNode;
       while (!found && (currentNode != null)) {
           if (anEntry.equals(currentNode.getData()))
               found = true;
           else
               currentNode = currentNode.getNextNode();
       }
       return found;
   }
   public int getLength() {
       return numberOfEntries;
      
   }
   public boolean isEmpty()
   {
       boolean result;
       if (numberOfEntries == 0) // Or getLength() == 0
       {
           // Assertion: firstNode == null
           result = true;
       }
       else
       {
           // Assertion: firstNode != null
           result = false;
       }
       return result;
   }
   private void initializeDataFields()
   {
       firstNode = null;
       numberOfEntries = 0;
   }
   private Node getNodeAt(int givenPosition)
   {
       Node currentNode = firstNode;
       for (int counter =1; counter < givenPosition; counter++)
           currentNode = currentNode.getNextNode();
       return currentNode;
   }
   private class Node
   {
       private T data;
       private Node next;
      
       private Node(T dataPortion) {
           data = dataPortion;
           next = null;
       }
      
       private Node(T dataPortion, Node nextNode) {
           data = dataPortion;
           next = nextNode;
       }
       private T getData() {
           return data;
       }
       private void setData(T newData) {
           data = newData;
       }
       private Node getNextNode()
       {
           return next;
       }
       private void setNextNode(Node nextNode) {
           next = nextNode;
       }
   }
  
  
}

In: Computer Science