Questions
****************************************Instructions**************************************************** I just need a test .cpp client file that tests the new bold bits of...

****************************************Instructions****************************************************

I just need a test .cpp client file that tests the new bold bits of code of the courseListType class.

It can be relatively simple. :)

Just want to let you know this is Part 2 of the question previously answered at:

https://www.chegg.com/homework-help/questions-and-answers/right-courselisttype-hold-static-50-courses-need-make-little-flexible-want-change-static-a-q57690521

***********************************************************************************************************

//courseTypeList.h

#ifndef COURSELISTTYPE_H_INCLUDED
#define COURSELISTTYPE_H_INCLUDED

#include
#include "courseType.h"

class courseTypeList {

public:
void print() const;
void addCourse(std::string);
courseTypeList(int n);
~courseTypeList();

private:
int NUM_COURSES;
int courseCount;
courseType *courses;
};

#endif // COURSELISTTYPE_H_INCLUDED

====================================================

//courseTypeList.cpp

#include
#include
#include "courseTypeList.h"

void courseTypeList::print() const {

for (int i = 0; i < courseCount; i++) {
courses[i].printCourse();
}
}

void courseTypeList::addCourse(std::string name) {
courses[courseCount++].setCourseName(name);
}

/* This allocates the array of the provided size, if no size is provided, default is 50 */

courseTypeList::courseTypeList(int n = 50)
{
   courseCount = 0;
   courses = new courseType[n];
   NUM_COURSES = n;
}

/* destructor to for CourseListType to deallocate space whenever a declared object goes out of scope. */

courseTypeList::~courseTypeList()
{
   delete courses;
}

***************************************************************************************************************

Just showing the courseType files as a reference for pieces of code in courseListType files.

***************************************************************************************************************

//courseType.h

#ifndef COURSETYPE_H_INCLUDED
#define COURSETYPE_H_INCLUDED
#include
#include

using namespace std;

class courseType {

public:
courseType(int, string);
courseType();

int getCourseID();
string getCourseName();

void setCourseID(int);
void setCourseName(string);

void printCourse();

private:
int courseID;
string courseName;

};

#endif

===================================================

//courseType.cpp

#include "courseType.h"
#include

using namespace std;

courseType::courseType(int id, string name) {
this-> courseID = id;
this-> courseName = name;
}

int courseType::getCourseID() {
return courseID;
}

string courseType::getCourseName() {
return courseName;
}

void courseType::setCourseID(int id) {
courseID = id;
}

void courseType::setCourseName (string name) {
courseName = name;
}


courseType::courseType()
{
   ;
}

void courseType::printCourse() {
cout << "Course ID: " << getCourseID() << endl;
cout << "Course Name: " << getCourseName() << endl;
}

In: Computer Science

What are the four agile manifestos? Describe each of the manifestos with examples

  1. What are the four agile manifestos? Describe each of the manifestos with examples

In: Computer Science

( Emotet, CovidLock, Mirai, Stuxnet & WannaCry) Describe in 600 words each of these  and provide a...

( Emotet, CovidLock, Mirai, Stuxnet & WannaCry) Describe in 600 words each of these  and provide a case study for each of these.

Try to answer it as a document.

In: Computer Science

Code in C++ Must show: unit testing ------------------------------------ UsedFurnitureItem Create a class named UsedFurnitureItem to represent...

Code in C++

Must show: unit testing

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

UsedFurnitureItem

  1. Create a class named UsedFurnitureItem to represent a used furniture item that the store sells.
  2. Private data members of a UsedFurnitureItem are:
    1. age (double) // age in years – default value for
    2. brandNewPrice (double) // the original price of the item when it was brand new
    3. description (string) // a string description of the item
    4. condition (char) // condition of the item could be A, B, or C.
    5. size (double) // the size of the item in cubic inches.
    6. weight (double) // the weight of the item in pounds.
  3. Private member functions of a UsedFurnitureItem object are
    1. double CalculateCurrentPrice( ): Current price depends on age, brandNewPrice, and condition of the used furniture Item. If the item is in A-condition, the current price will go down by extra 10% of the brandNewPrice for each year of its age until 7 years (e.g., After the first year, and item with a $100 brandNewPrice will cost $90, after 2 years, $ 80, and so on). If the age is greater than 7 years, the price is fixed at 30% of the brandNewPrice. The current price of B-condition items goes down by extra 15 % of the brandNewPrice for each year until the 5th year. After that, the current price is fixed at 20% of the brandNewPrice. Items with C-condition are priced at 10% of the brandNewPrice regardless of age.
    1. double CalculateShippingCost( ): Shipping cost of a UsedFurnitureItem depends on weight, size, and distance. While weight and size are member variables, shipping distance is provided as an additional argument to this function. Shipping rate is 1 cent per mile for items that are smaller than 1000 cubic inches and smaller than 20 pounds. Items with larger size or weight cost 2 cents per mile.
  4. Public member functions of a UsedFurnitureItem
    1. Constructors – default and overloaded [default values: age = 1.0, brandNewPrice = 10.00, description = “Not available”, condition = ‘A’, size = 1.0, weight = 1.0]
    2. Accessors (getters)
    1. Mutators (setters) – You should ensure that invalid (zero or negative) values do not get assigned to age, brandNewPrice, size or weight data members. An invalid character (other than ‘A’, ‘B’ or ‘C’) should not be allowed to be assigned

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

Test Program:

The test program will test each setter (for objects of both types in a sequence) by calling the setter to set a value and then call the corresponding getter to print out the set value. This test should be done twice on data members that could be set to invalid values (that have numerical or character data type) – once after trying to set invalid values and subsequently, once after setting them to valid values. The data members with string data types (model, description) can be tested just once.

In: Computer Science

What are basic characteristics of a self-organization team and steps to become self-organized? (from an agile...

What are basic characteristics of a self-organization team and steps to become self-organized? (from an agile methodology point of view)

In: Computer Science

What is poker planning in Agile estimation? What does it estimate? Why is it effective?

What is poker planning in Agile estimation? What does it estimate? Why is it effective?

In: Computer Science

Describe how the Heartbleed attack happens. What is the type of this attack? Where does the...

Describe how the Heartbleed attack happens. What is the type of this attack? Where does the vulnerability exist? Describe the vulnerability and how it is exploited? Describe the consequences of the attack?

In: Computer Science

Provide a brief (1- to 3-paragraph) analysis of the Heartbleed vulnerability. In your response, be sure...

Provide a brief (1- to 3-paragraph) analysis of the Heartbleed vulnerability. In your response, be sure to address the following:

  • Describe the cause of the vulnerability.
  • Identify the secure coding principles that were violated.
  • Recommend best practices to identify or prevent similar attacks.

In: Computer Science

An Armstrong number is a number that is the sum of its own digits, each raised...

An Armstrong number is a number that is the sum of its own digits, each raised to the power of the number of its digits. For example, 153 is considered an Armstrong number because 13 + 53 + 33 = 153.

Write a VBA program that lists all 3-digit Armstrong numbers within a specified range of 3-digit positive integers. Your sub should do the following: 1) Using two input boxes, ask the user to input two 3-digit positive integers (a "lower bound" and an "upper bound" for the range); 2) Enter all Armstrong numbers between the specified numbers in column A, staring with cell A1. Hints: Use a For Loop. Also, string functions can be used on LONG variables.

In: Computer Science

Java the goal is to create a list class that uses an array to implement the...

Java the goal is to create a list class that uses an array to implement the interface below. I'm having trouble figuring out the remove(T element) and set(int index, T element). I haven't added any custom methods other than a simple expand method that doubles the size by 2. I would prefer it if you did not use any other custom methods. Please use Java Generics, Thank you.

import java.util.*;

/**
* Interface for an Iterable, Indexed, Unsorted List ADT.
* Iterators and ListIterators provided by the list are required
* to be "fail-fast" and throw ConcurrentModificationException if
* the iterator detects any change to the list from another source.
* Note: "Unsorted" only means that it is not inherently maintained
* in a sorted order. It may or may not be sorted.
*
* @author CS 221
*
* @param - class of objects stored in the list
*/
public interface IndexedUnsortedList extends Iterable
{
/**
* Adds the specified element to the front of this list.
*
* @param element the element to be added to the front of this list
*/
public void addToFront(T element);

/**
* Adds the specified element to the rear of this list.
*
* @param element the element to be added to the rear of this list
*/
public void addToRear(T element);

/**
* Adds the specified element to the rear of this list.
*
* @param element the element to be added to the rear of the list
*/
public void add(T element);

/**
* Adds the specified element after the specified target.
*
* @param element the element to be added after the target
* @param target the target is the item that the element will be added after
* @throws NoSuchElementException if target element is not in this list
*/
public void addAfter(T element, T target);
  
/**
* Inserts the specified element at the specified index.
*
* @param index the index into the array to which the element is to be inserted.
* @param element the element to be inserted into the array
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index > size)
*/
public void add(int index, T element);

/**
* Removes and returns the first element from this list.
*
* @return the first element from this list
* @throws NoSuchElementException if list contains no elements
*/
public T removeFirst();

/**
* Removes and returns the last element from this list.
*
* @return the last element from this list
* @throws NoSuchElementException if list contains no elements
*/
public T removeLast();

/**
* Removes and returns the first element from the list matching the specified element.
*
* @param element the element to be removed from the list
* @return removed element
* @throws NoSuchElementException if element is not in this list
*/
public T remove(T element);

/**
* Removes and returns the element at the specified index.
*
* @param index the index of the element to be retrieved
* @return the element at the given index
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size)
*/
public T remove(int index);
  
/**
* Replace the element at the specified index with the given element.
*
* @param index the index of the element to replace
* @param element the replacement element to be set into the list
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size)
*/
public void set(int index, T element);

/**
* Returns a reference to the element at the specified index.
*
* @param index the index to which the reference is to be retrieved from
* @return the element at the specified index
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size)
*/
public T get(int index);

/**
* Returns the index of the first element from the list matching the specified element.
*
* @param element the element for the index is to be retrieved
* @return the integer index for this element or -1 if element is not in the list
*/
public int indexOf(T element);

/**
* Returns a reference to the first element in this list.
*
* @return a reference to the first element in this list
* @throws NoSuchElementException if list contains no elements
*/
public T first();

/**
* Returns a reference to the last element in this list.
*
* @return a reference to the last element in this list
* @throws NoSuchElementException if list contains no elements
*/
public T last();

/**
* Returns true if this list contains the specified target element.
*
* @param target the target that is being sought in the list
* @return true if the list contains this element, else false
*/
public boolean contains(T target);

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

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

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

/**
* Returns an Iterator for the elements in this list.
*
* @return an Iterator over the elements in this list
*/
public Iterator iterator();

/**
* Returns a ListIterator for the elements in this list.
*
* @return a ListIterator over the elements in this list
*
* @throws UnsupportedOperationException if not implemented
*/
public ListIterator listIterator();

/**
* Returns a ListIterator for the elements in this list, with
* the iterator positioned before the specified index.
*
* @return a ListIterator over the elements in this list
*
* @throws UnsupportedOperationException if not implemented
*/
public ListIterator listIterator(int startingIndex);
}

In: Computer Science

Coding Project 2: UDP Pinger In this lab, you will learn the basics of socket programming...

Coding Project 2: UDP Pinger

In this lab, you will learn the basics of socket programming for UDP in Python. You will learn how to send and receive datagram packets using UDP sockets and also, how to set a proper socket timeout. Throughout the lab, you will gain familiarity with a Ping application and its usefulness in computing statistics such as packet loss rate.

You will first study a simple Internet ping server written in the Python, and implement a corresponding client. The functionality provided by these programs is similar to the functionality provided by standard ping programs available in modern operating systems. However, these programs use a simpler protocol, UDP, rather than the standard Internet Control Message Protocol (ICMP) to communicate with each other. The ping protocol allows a client machine to send a packet of data to a remote machine, and have the remote machine return the data back to the client unchanged (an action referred to as echoing). Among other uses, the ping protocol allows hosts to determine round-trip times to other machines.

You are given the complete code for the Ping server below. Your task is to write the Ping client.

Server Code

The following code fully implements a ping server. You need to compile and run this code before running your client program. You do not need to modify this code.

In this server code, 30% of the client’s packets are simulated to be lost. You should study this code carefully, as it will help you write your ping client.

# UDPPingerServer.py


# We will need the following module to generate randomized lost packets import random
from socket import *

# Create a UDP socket
# Notice the use of SOCK_DGRAM for UDP packets

serverSocket = socket(AF_INET, SOCK_DGRAM)


# Assign IP address and port number to socket

serverSocket.bind(('', 12000))

while True:


# Generate random number in the range of 0 to 10
rand = random.randint(0, 10)
# Receive the client packet along with the address it is coming from message, address = serverSocket.recvfrom(1024)
# Capitalize the message from the client
message = message.upper()

# If rand is less is than 4, we consider the packet lost and do not respond if rand < 4:

continue

# Otherwise, the server responds

serverSocket.sendto(message, address)

The server sits in an infinite loop listening for incoming UDP packets. When a packet comes in and if a randomized integer is greater than or equal to 4, the server simply capitalizes the encapsulated data and sends it back to the client.

Packet Loss

UDP provides applications with an unreliable transport service. Messages may get lost in the network due to router queue overflows, faulty hardware or some other reasons. Because packet loss is rare or even non-existent in typical campus networks, the server in this lab injects artificial loss to simulate the effects of network packet loss. The server creates a variable randomized integer which determines whether a particular incoming packet is lost or not.

Client Code

You need to implement the following client program.
The client should send 10 pings to the server. Because UDP is an unreliable protocol, a packet sent from the client to the server may be lost in the network, or vice versa. For this reason, the client cannot wait indefinitely for a reply to a ping message. You should get the client wait up to one second for a reply; if no reply is received within one second, your client program should assume that the packet was lost during transmission across the network. You will need to look up the Python documentation to find out how to set the timeout value on a datagram socket.

Specifically, your client program should
(1) send the ping message using UDP (Note: Unlike TCP, you do not need to establish a connection first, since UDP is a connectionless protocol.)
(2) print the response message from server, if any
(3) calculate and print the round trip time (RTT), in seconds, of each packet, if server responses
(4) otherwise, print “Request timed out”

During development, you should run the UDPPingerServer.py on your machine, and test your client by sending packets to localhost (or, 127.0.0.1). After you have fully debugged your code, you should see how your application communicates across the network with the ping server and ping client running on different machines.

Message Format

The ping messages sent to the server in this project are formatted in a simple way. The client message is one line, consisting of ASCII characters in the following format:

Ping sequence_number time

where sequence_number starts at 1 and progresses to 10 for each successive ping message sent by the client, and time is the time when the client sends the message.

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

I cannot get my version to work, please follow the instructions.

In: Computer Science

Modify the program to double each number in the vector. #include <iostream> #include <vector> using namespace...

Modify the program to double each number in the vector.

#include <iostream>
#include <vector>
using namespace std;

int main() {
   const int N=8;
   vector<int> nums(N); // User numbers
   int i=0; // Loop index
   cout << "\nEnter " << N << " numbers...\n";
   for (i = 0; i < N; ++i) {
      cout << i+1 << ": ";
      cin >> nums.at(i);
   }
   // Convert negatives to 0
   for (i = 0; i < N; ++i) {
      if (nums.at(i) < 0) {
         nums.at(i) = 0;
      }
   }
   // Print numbers
   cout << "\nNew numbers: ";
   for (i = 0; i < N; ++i) {
      cout << " " << nums.at(i);
   }
   cout << "\n";

   return 0;
}

In: Computer Science

Part1: 1.An algorithm is . a) a series of actions that solve a particular problem. b)...

Part1:

1.An algorithm is .

a) a series of actions that solve a particular problem.

b) an english description of a problem to be solved.

c) the process of converting between data types.

d) None of the above.

2. Program control is best defined as .

a) the degree of control a program has over the computer on which it is executed.

b) the line of code that is executing at a given time.

c) the order in which a series of statements is executed.

d) None of the above.

3. Pseudocode is a(n) .

a) hybrid language of all object-oriented languages.

b) artificial language used to develop algorithms.

c) language used to translate from Python to assembly language.

d) None of the above.

4.Pseudocode is most comparable to .

a) C#.

b) C.

c) Pascal.

d) English.

5.Which of the following is a type of control structure?

a) declaration structure.

b) repetition structure.

c) flow structure.

d) All of the above.

6.A transfer of control occurs when a .

a) program changes from input to output, or vice versa

b) logic error occurs in a program

c) statement other than the next one in the program executes

d) None of the above

7.

The three types of selection structures are , and :

a) for , if , if /else .

b) for , while , if .

c) if , if /else , while .

d) if , if /else , if /elif /else .

8.

What capability does if /else provide that if does not?

a) the ability to execute actions when the condition is false.

b) the ability to nest structures.

c) the ability to stack structures.

d) None of the above.

9.

Python prints a(n) when a fatal logic error occurs.

a) logic message.

b) traceback.

c) exception.

d) None of the above.

10.

Which of the following results in a fatal logic error?

a) attempting to add numbers that have not been converted from string format.

b) dividing by zero.

c) forgetting a colon in an if structure.

d) All of the above.

11. Which of the following statements would cause a while structure to stop

executing?

a) 3 <= 11 .

b) !(7 != 14) .

c) 6 != 9 .

d) All of the above.

12.

In a(n) , the body of a while structure never stops executing.

a) syntax error.

b) fatal error.

c) infinite loop.

d) None of the above.

13. A can be used in a repetition structure to control the number of times a

set of statements will execute.

a) declaration.

b) counter.

c) controller.

d) None of the above.

14.

A can be used in repetition structures to indicate the end of data entry.

a) counter.

b) boolean.

c) sentinel value.

d) None of the above.

15. The expression a *= 4 is correctly represented by:

a) a = 4 * 4 .

b) a = 4a .

c) a = a * 4 .

d) None of the above.

16. Counting loops should be controlled with values.

a) floating-point.

b) integer.

c) string.

d) None of the above.

17. The function call produces the same sequence as range( 10 ) .

a) range( 1, 10 ) .

b) range( 10, 1 ) .

c) range( 0, 10, 1 ) .

d) None of the above.

18. The characters %21.2f indicate a floating-point value will be printed with

how many positions to the left of the decimal point?

a) 21.

b) 18.

c) 2.

d) 19.

19.

The statement, when executed in a while loop, skips the remaining

statements in the body of the structure and begins the next iteration of the loop.

a) continue .

b) break .

c) next .

d) None of the above.

20.

The logical and operator ensures that .

a) two conditions are true.

b) at least one condition is true.

c) two conditions are false.

d) None of the above.

21.

Python provides the operator to reverse the meaning of a condition.

a) opposite .

b) not .

c) reverse .

d) All of the above.

Part2:

1.The small, simple pieces that are used to construct programs are typically

referred to as .

a) components.

b) segments.

c) sections.

d) None of the above.

2. A function is invoked by a .

a) function call.

b) function header.

c) declaration.

d) None of the above.

3.

Variables declared in function definitions are variables.

a) global.

b) local.

c) constant.

d) None of the above.

4.

Functions are called by writing the name of the function followed by zero or

more enclosed in parentheses.

a) conditions.

b) arguments.

c) counters.

d) None of the above.

5.

Which of the following correctly calls the math module function sqrt with

a value of 36?

a) math(sqrt, 36) .

b) math.sqrt(36) .

c) math.sqrt = 36 .

d) None of the above.

6.

Which of the following is a correct function definition header?

a) def count (x,y) .

b) def count (x,y): .

c) count (x,y): .

d) None of the above.

7. _____is a Python value that represents null.

a) None .

b) Null .

c) Nothing .

d) None of the above.

8. The capability of random-number generation is provided in the module .

a) rng .

b) random .

c) rand .

d) None of the above.

9. A recursive function is a function that .

a) calls another function.

b) calls itself.

c) does not return a value.

d) None of the above.

10. Iteration uses a structure, whereas recursion uses a structure.

a) repetition, selection.

b) sequence, repetition.

c) selection, repetition.

d) selection, sequence.

11. A difference between recursion and iteration is that:

a) iteration involves an explicit repetition structure unlike recursion.

b) recursion is associated with a counter controlled repetition.

c) iteration cannot execute infinitely, like recursion.

d) None of the above.

In: Computer Science

We are trying to use two stacks to implement a queue. Name the two stacks as...

We are trying to use two stacks to implement a queue. Name the two stacks as E and D. We will enqueue into E and dequeue from D. To implement enqueue(e), simply call E.push(e). To implement dequeue(), simply call D.pop(), provided that D is not empty. If D is empty, iteratively pop every element from E and push it onto D, until E is empty, and then call D.pop().

  1. Considering the worst case running time, what is the performance in terms of big Oh of an enqueue operation? What is the performance in terms of big Oh of a dequeue operation?
  2. To complete one task, we need perform n operations, half enqueue and half dequeue (assume no dequeue from empty queue). What is the worst case overall running time (big oh) for the whole task?

In: Computer Science

In my object java class the question is that it is possible to have direct inputs...

In my object java class the question is that it is possible to have direct inputs and outputs within the setters and getters, it is highly discouraged to achieve full portability of the code. Explain why.

In: Computer Science