Questions
goal Find the average of the elements in the list (list could have any number of...

goal Find the average of the elements in the list (list could have any number of elements).
If the average is a decimal number, return only the integer part. Example: if average=10.8, return 10
Example: if list={10, 20, 30, 40, 50}, the method should return: 30

import java.io.*;
import java.util.Scanner;

class Node {
int data;
Node next;
Node(int d){ // Constructor
   data = d;
   next = null;
}
}

class LinkedList {// a Singly Linked List
   Node head; // head of list
   public void insert(int data){ // Method to insert a new node
       Node new_node = new Node(data); // Create a new node with given data
       new_node.next = null;
       if (head == null) // If the Linked List is empty, then make the new node as head
           head = new_node;
       else {// Else traverse till the last node and insert the new_node there
           Node last = head;
           while (last.next != null)
               last = last.next;
           last.next = new_node; // Insert the new_node at last node
       }
   }
}

class Main {
public static void main(String[] args)
   {
       LinkedList list = new LinkedList();/* Start with the empty list. */
       Scanner scan = new Scanner(System.in);
       int num;
       for (int i=0; i<10; i++){//Read list values
           num = scan.nextInt();
           list.insert(num);
       }
System.out.println(""+getAvg(list));
   }

   
public static int getAvg(LinkedList list) {
       //goal Find the average of the elements in the list (list could have any number of elements).
      
       //If the average is a decimal number, return only the integer part. Example: if average=10.8, return 10
       //Example: if list={10, 20, 30, 40, 50}, the method should return: 30

      
   }

}

In: Computer Science

Using C++. Implement l_list.cpp and l_list.h l_list and encounterNode. The former is a richly featured linked...

Using C++. Implement l_list.cpp and l_list.h

l_list and encounterNode. The former is a richly featured linked list with a wide variety of methods and the latter is a node meant to encapsulate a game encounter. In the context of this task, the encounterNode represents a battle encounter. Each encounter will describe what a player has to watch in the course of the level in terms of enemies, rewards and such. Therefore a combination of encounterNodes contained within a linked list would represent a single level in a game. The classes and behaviors of their methods are detailed below:

l_list
-head: encounterNode*
---------------------------
+l_list()
+~l_list()
+addToFront(a:string*, b:int, c:string):int
+addToBack(a:string*, b:int, c:string):int
+addAtIndex(a:string*, b:int, c:string, index:int):int
+getListSize():int
+removeFromFront():encounterNode*
+removeFromBack():encounterNode*
+removeFromIndex(index:int):encounterNode*
+printSummaryOfList():void
+printList():void

The class has the following variables:
•head: The head pointer which demarcates the start of the list.

The class has the following methods:
•l_list: The list constructor. It will start by initialising a blank list with no elements.

•∼l_list: The list destructor. It should delete all of the remaining nodes in the list and deallocate all of the memory contained within. After deleting the list, it should print out the following message: ”Number of nodes deleted: X” without quotation marks where X indicates the number of nodes deleted in the process. Be sure to add a newline at the end of this output.

•addToFront: This method receives the variables to construct a new node and then allocates memory for it before adding it to the list at the front. It returns the new size of the list, that is the size of the list with the added node.

•addToBack: This method receives the variables to construct a new node and then allocates memory for it before adding it to the list at the back of the list. It returns the new size of the list, that is the size of the list with the added node.

•addAtIndex: This method receives the variables required to instantiate a new node as well as an index. This method should insert this node into the list at the given index. If the given index is not contained within the list, such as inserting at 5 when the list is only 2 nodes big, instead you must add it to the front. Note that the list is 0-indexed. It returns the new size of the list, that is the size of the list with the added node.

•getListSize: This method determines the number of nodes in the list and returns this as an integer.

•removeFromFront: This remove method removes a node from the list from the front and returns it. Note that the node is returned and not deleted; it must be properly unlinked from the list without being destroyed. If the list is empty, return NULL.

•removeFromBack: This remove method removes a node from the list from the back and returns it. Note that the node is returned and not deleted; it must be properly unlinked from the list without being destroyed. If the list is empty, return NULL.

•removeFromIndex: This method receives an index of a node to remove from the list. This node must be removed and returned without being destroyed; that is, unlinked from the list without being deleted. Note that if the index is not valid or the list is empty then the method should return NULL. The list is 0-indexed.

•printList: This method prints out the entire list, starting from the front. If the list is empty, print ”EMPTY LIST” without the quotation marks and a newline at the end. The example output is given below:
       Node 0
       Number of Enemies: 2
       Reward: Boots of Healing
       Enemy 1: Imp
       Enemy 2: Imp
       Node 1
       Number of Enemies: 2
       Reward: Sword of Revealing Light
       Enemy 1: Mancubus
       Enemy 2: Hell Knight

•printSummaryOfList: This method is a more sophisticated type of print. Instead of merely printing out of the full information of the list, it aggregates and collates the information from the list into a more easily readable report. If the list is empty,
print ”EMPTY LIST” without the quotation marks and a newline at the end. The report determines the following pieces of information:
       1.The number of nodes in the list.
       2.The number of enemies, in total in the list.
       3.The number of rewards which are healing to the player, that is if the reward has Healing or Health in its name. You can assume that the case will match the specific form of Healing or Health.
Therefore the output of this print operation takes the form (considering the prior example as the list):

       Number of Nodes: 2
       Number of Enemies: 4
       Number of Healing Rewards: 1

You are only allowed the use of the following libraries: string and iostream.

===================encounterNode.h=====================

#ifndef ENCOUNTER_NODE_H
#define ENCOUNTER_NODE_H
#include<iostream>
#include<string>
using namespace std;

class encounterNode
{
   private:
       string* enemies;
       int numEnemies;
       string reward;
   public:
       encounterNode* next;
       encounterNode(string* list, int numE, string re);
       ~encounterNode();
       string* getEnemies() const;
       void setEnemies(string* a, int b);
       string getEnemyAtIndex(int a);
       void setEnemyAtIndex(int a, string b);
       string getReward() const;
       void setReward(string a);
       int getNumEnemies() const;
       void setNumEnemies(int a);
       void print();
};
#endif

===================encounterNode.cpp=====================

#include "encounterNode.h"
#include<iostream>
#include<string>
using namespace std;

encounterNode::encounterNode(string* list, int numE, string re)
{
   enemies = list;
   numEnemies = numE;
   reward = re;
}

encounterNode::~encounterNode()
{
   delete [] enemies;
}

string* encounterNode::getEnemies() const
{
   return enemies;
}

void encounterNode::setEnemies(string* a, int b)
{
   if (enemies != NULL)
       delete[]enemies;

   enemies = new string[b];
   for (int i = 0; i < b; i++)
       enemies[i] = a[i];

   numEnemies = b;
}

string encounterNode::getEnemyAtIndex(int a)
{
   if (a >= 0 && a < numEnemies)
       return enemies[a];
   else
       return "";
}

void encounterNode::setEnemyAtIndex(int a, string b)
{
   if (a >= 0 && a < numEnemies)
       enemies[a] = b;
}

string encounterNode::getReward() const
{
   return reward;
}

void encounterNode::setReward(string a)
{
   reward = a;
}

int encounterNode::getNumEnemies() const
{
   return numEnemies;
}

void encounterNode::setNumEnemies(int a)
{
   numEnemies = a;
}

void encounterNode::print()
{
   cout << "Number of Enemies: " << numEnemies << endl;
   cout << "Reward: " << reward << endl;
   for (int i = 0; i < numEnemies; i++)
   {
       cout << "Enemy " << (i + 1) << ": " << enemies[i] << endl;
   }
   cout << endl;
}

In: Computer Science

List and discuss the 3 types of firms. What is market failure?  List the roles of...

List and discuss the 3 types of firms.


What is market failure?


 List the roles of government.


Why does international trade occur? What is the exchange rate?

In: Economics

Q1. List and explain the four parts of the scientific method. Q2. List and explain the...

Q1. List and explain the four parts of the scientific method.

Q2. List and explain the seven characteristics typical of all living things.

Q3. List and describe the functions of the organelles found in eukaryotic cells.

Q4. Explain the relationship between DNA replication and cell division.

Next five Questions 5 to 9 are on this link -->  https://www.chegg.com/homework-help/questions-and-answers/q5-define-ecology-terms-biotic-abiotic-community-population-ecosystem-explain-related-q6-e-q30048335

In: Biology

Define Marketing? Define what an exchange is and list the five conditions of an exchange? List...

Define Marketing?

Define what an exchange is and list the five conditions of an exchange?

List and define the Four Marketing Management Philosophies?

What is a Marketing Plan and what is the purpose of a marketing plan?

List and define the four elements of the marketing mix “Four Ps.”

Explain what the two types of products are and provide an example of each.

List the seven steps in the New Product Development Process.

Discuss briefly the four major stages of the Product Life Cylce.

Explain what Supply Chain and Supply Chain Management are.

Discuss the Benefits of Supply Chain Management.

What are the two channel intermediaries and briefly discuss the most prominent difference separating the two channel intermediaries.

List the three types of Channel Relationships.

List and explain what the Four Tasks of Promotion are.

Briefly discuss the two types of Advertising and their purpose.

Explain what the Role of Public Relations is.

In: Finance

For Questions 4 and 5, use the list of reasons provided below: List of Reasons for...

For Questions 4 and 5, use the list of reasons provided below:

List of Reasons for Intervention

Risk Aversion and Risk Trading

Monopoly Power or Market Power

Negative Externality

Positive Externality

Public Good

Asymmetric Information/Adverse Selection

Moral Hazard or Hidden Action.

  1. Some insurance companies require individuals to take a blood test before qualifying for lower health insurance premiums. a.Identify the problem that insurance companies are trying to address. Choose from list above. (1 point) b. Briefly explain how the proposed solution remedies the inefficiency. (2 points)
  2. Many employment contracts offer their employees stock options in the company as part of their compensation. a. Identify the problem that employers are trying to address with this compensation. Choose from list above. (1 point) b.Briefly explain how the proposed solution remedies the inefficiency. (2 points)

In: Economics

Briefly analyze the ratios, then Construct only a list of strengths and a list weaknesses. Gallery...

Briefly analyze the ratios, then Construct only a list of strengths and a list weaknesses.

Gallery of Dreams

Ratios

Ratio

Industry

2015

2014

2013

Current

2.50x

4.48x

4.06x

3.48x

Quick

0.80x

1.47x

1.18x

0.96x

Average collection period

11 days

16 days

15 days

9 days

Inventory turnover

2.30x

1.19x

1.24x

1.37x

Days payable outstanding

15 days

11 days

12 days

8 days

Fixed asset turnover

17.50x

9.74x

9.09x

8.85x

Total asset turnover

2.80x

1.50x

1.67x

1.82x

Debt ratio

62.00%

29.47%

34.04%

39.17%

Long term debt to

total capitalization

25.53%

14.09%

18.91%

22.33%

Times interest earned

9.93x

22.02x

19.00x

14.23x

Fixed charge coverage

8.69x

4.59x

4.47x

4.25x

Gross profit margin

31.10%

59.21%

59.39%

58.52%

Operating profit margin

8.06%

22.05%

21.86%

20.52%

Net profit margin

4.32%

11.89%

11.00%

10.97%

Return on investment

9.21%

17.97%

18.28%

18.35%

Return on equity

11.34%

24.14%

27.51%

29.88%

In: Finance

Explain and list the types of unemployment. Explain and list the types of inflation. Thank you.

Explain and list the types of unemployment.

Explain and list the types of inflation.

Thank you.

In: Economics

List the roots that give rise to the brachial plexus List the most common syndromes that...

List the roots that give rise to the brachial plexus

List the most common syndromes that arise from an injury of the roots of the brachial plexus

Organize the brachial plexus based on its divisions

List the functions of each terminal branch of the brachial plexus

Organize the sensory innervation of the upper limb based on the specific branch of the brachial plexus

List the most common places for an injury of a terminal branch of the brachial plexus (example:

Radial nerve at the radial groove)

Identify the location of an injury of the brachial plexus based on the neurological deficits

Contrast a proximal ulnar nerve injury with a distal ulnar nerve injury

Contrast a proximal median nerve injury with a distal median nerve injury

List the signs and symptoms of carpal tunnel syndrome

In: Anatomy and Physiology

What is an array-based list? What is a resizable list? What is the difference between a...

What is an array-based list?


What is a resizable list?


What is the difference between a list’s capacity and its size?


When a list is expanded, is the size changed or is its capacity changed?

In: Computer Science