Questions
c++ please Your task is to write the implementation for a class of polynomial operations. Your...

c++ please

Your task is to write the implementation for a class of polynomial operations. Your will write the code for: 2 constructors, a destructor, print, addition, multiplication , differentiation and integration of polynomials. The polynomials will be comprised of linked TermNodes.

struct TermNode
{
int   exp; // exponent
double coef; // coefficient
TermNode * next;
};
class Polynomial
{
  public:
     Polynomial ();              // default constructor 
     Polynomial (int r, int c);                      // constructor makes a 1 node polynomial
    Polynomial(const Polynomial & );    // copy constructor
     ~Polynomial ();                 // destructor
                                           
     Polynomial   operator=(const Polynomial &); // assignment
     Polynomial   operator+ (const Polynomial & ) const;     // returns sum of the parameter + self 
     Polynomial   operator* (const Polynomial & ) const;
     Polynomial   differentiation();
     Polynomial   integration ();// (with 0 as the constant)              
     friend ofstream &   operator<< (ofstream & out, const Polynomial & rhs);           // coefficients printed to 2 decimal places
  private:
     TermNode  *firstTerm;  
     
};

Example Use of functions
Polynomial poly1; //makes a null polynomial 
Polynomial poly2(2,3); // makes the polynomial 2.00x^3 
Polynomial poly3(3,4); // makes the polynomial 3.00x^4 
poly1 = poly2 + poly3; // makes poly1 = 3.00x^4 + 2.00x^3 
cout<<poly1<<endl;  // prints out 3.0x^4 + 2.00x^3 
poly3 = poly2*poly1; // sets poly3 to 6.0x^7+4.00x^6 
poly4 = poly3.differentiation(); // sets poly4 to 42.00x^6+24.00x^5 
poly5 = poly1.integration(); // sets poly5 to .60x^5+.50x^4 

In: Computer Science

in Python3 The ord function in Python takes a character and return an integer that represents...

in Python3

The ord function in Python takes a character and return an integer that represents that character.
It does not matter what the integer representing the character actually is, but what matters is this:

ord('a') is 1 less than ord('b'), so that:

x=ord('a')
thisLetter = x+1 # thisLetter is the ord('b')

This is a powerful fact that is used in encryption techniques, so data transferred over the web is 'ciphered so it is unreadable to others.

To decipher data, we take a string and change it into another string by adding a constant (called the key) to each of its letters' ord value.
See the book's Case study: word play.

To cipher and decipher data, we need two functions: one to take a string, and change it to something else. For this we need to use the ord function, and add the 'key' to result in a new string. For example, say x is one letter to be ciphered, and the key is 3. We can use:

Newx=ord(x)+3

Newx will be an integer. To find out what letter that integer represents you can use the chr function as in:
actualLetter = chr(x)

Write a function named cipher that takes a string.
The function returns that string in a ciphered form by using the ord of the first letter of the string to cipher each letter including the first letter. Hence for abc, use the ord of 'a', and add it to the ord of 'a' and convert that result to a character use the chr function. This character should be concatenated to the same action on the letter b and so on. Hence the function returns:

chr(ord('a')+ord('a')) + chr(ord('a')+ord('b')) + chr(ord('a')+ord('c')).
Obviously you need a loop to iterate on each letter.

Write another function to decipher (do the opposite of the previous function), given a string and returns the deciphered string. Obviously, the first letter's ord is halved to find the first letter, and that value is used to decipher the remaining letters.

From main, write code to get a string, as input, then call the cipher function and print its output.
Then call the decipher function and display its output. The decipher output should match the original string.

For help on this see the book's Case study: word play.

Add comments as needed but make sure to add top level comments.

In: Computer Science

There are different types of software testing techniques as described below. There is no uniform (standard)...

There are different types of software testing techniques as described below. There is no uniform (standard) best software testing technique. Each has its own benefits.

-Black box testing: based on functional requirements.

-White box testing: ensure that all statements and conditions have been executed at least once

-Manual software testing is time consuming

-Regression testing: Software testing has to be repeated after every change

Explain the following testing techniques and justify the statement - "There is no uniform (standard) best software testing technique."

Please help with this question and explain in your own words to avoid plagiarism. Thanks.

In: Computer Science

Pick a product/service of your choice. In this assignment you will provide a high level web...

Pick a product/service of your choice. In this assignment you will provide a high level web strategic plan for that product and service. Remember, as you are putting together that strategic plan, think of what's your high level objective of your website? Is it to sell product or get people to raise their hand (or generate leads) to learn more about the product. Provide details on the following sections for this "draft plan". Whats the objective of your website? Who's your target audience? What type of content (information) should you have on your site? Will you have mainly copy or graphics or both? Why? What is your content there to help you achieve? How will you generate traffic to your site? (social media, email, PPC, SEO, explain your plan here) What metrics will you measure to see if your plan and what you executed was successful? Give specific examples

In: Computer Science

Analyze the following code: public class Test {   public static void main(String[] args) { xMethod(5, 500L);...

Analyze the following code:

public class Test {
  public static void main(String[] args) {
xMethod(5, 500L);
  }

  public static void xMethod(int n, long l) {
    System.out.println("int, long");
  }

  public static void xMethod(long n, long l) {
    System.out.println("long, long");
  }
}

Group of answer choices

The program prints 2 lines: int, long long, long

The program contains a compile error because Java can't tell which method to invoke.

The program prints long, long

The program prints int, long

In: Computer Science

IN JAVA Write a program that calculates the occupancy rate for each floor of a hotel....

IN JAVA

Write a program that calculates the occupancy rate for each floor of a hotel. (Use a sentinel value and please point out the sentinel in bold.) The program should start by asking for the number of floors in the hotel. A loop should then iterate once for each floor. During each iteration, the loop should ask the user for the number of rooms on the floor and the number of them that are occupied. After all the iterations, the program should display the number of rooms the hotel has, the number of them that are occupied, the number that are vacant, and the occupancy rate for the hotel. Input Validation: Do not accept a value less than 1 for the number of floors. Do not accept a number less than 10 for the number of rooms on a floor.

SAMPLE OUTPUT:

Enter number of floors:
2
Enter total rooms at floor 1:
10
Enter total rooms occupied at floor1:
5
Enter total rooms at floor 2:
10
Enter total rooms occupied at floor2:
5
Total rooms: 20
Total occupied rooms: 20
Hotel occupany: 50.0

In: Computer Science

You are an IT company and want to get a daycare's network design, hardware, software, and...

You are an IT company and want to get a daycare's network design, hardware, software, and security. Project resources allocation. List all types of resources (e.g. human and non-human) you will use them in the enterprise network project. How are you planning to use those resources cost-effectively?

In: Computer Science

Tic-Tac-Toe, also called X's and O's, Noughts and Crosses, and X and 0 is a simple...

Tic-Tac-Toe, also called X's and O's, Noughts and Crosses, and X and 0 is a simple game played on a 3x3 grid, referred to as the board. Lines may be horizontal, vertical, or diagonal.

You will implement a Board class to represent the 3x3 grid. This class will have functions to determine which symbol, if any, is in a cell, to place a symbol in a cell, to determine the winner, if any so far, and to print the board to standard output. The board should appear as below:

Implement a Board class with the following functionality:

 Default constructor, copy constructor, destructor, assignment operator.

 Determine the symbol at the specified grid position.

 Change the symbol at the specified grid position.

 Determine the winner of the game, if any. You must distinguish between the case where there is no winner because the game is not over yet, and the case where there is no winner because the game ended in a tie.

Create four constants for the four game states and return one of them.

Find a way to pass the position in the grid as a single value. This can be done by creating a record (struct) to store the row and column, or by representing both values using a single integer.

 Print the board to standard output.

In: Computer Science

There are different types of software testing techniques as described below. Each has its own benefits....

There are different types of software testing techniques as described below. Each has its own benefits.

-Black box testing: based on functional requirements.

-White box testing: ensure that all statements and conditions have been executed at least once

Explain the following testing techniques and justify that "black box software testing is not an alternative to white box software testing"?

Please help with this question and explain in your own words to avoid plagiarism. Thanks.

In: Computer Science

Consider the set of strings A = {c,cc,ccc}. What is the shortest string the set of...

Consider the set of strings A = {c,cc,ccc}.
What is the shortest string the set of strings A5.

In: Computer Science

Topic: HTML Styling Elements - CSS3 Write some HTML code that includes three Semantic HTML tags....

Topic: HTML Styling Elements - CSS3

Write some HTML code that includes three Semantic HTML tags. Describe the semantic meaning of each one you choose.

In: Computer Science

Write a program in javascript to encrypt and decrypt the user input using the caesar algorithm...

Write a program in javascript to encrypt and decrypt the user input using the caesar algorithm with the substitution algorithm. Specify the min and max of the message user can enter to encrypt. Specify the length of the key user can enter to encrypt and decrypt the message. document your design by words or diagrams.

In: Computer Science

#include int main() {      FILE *fp1;      char c;      fp1= fopen ("C:\\myfiles\\newfile.txt", "r");     ...

#include

int main()

{

     FILE *fp1;

     char c;

     fp1= fopen ("C:\\myfiles\\newfile.txt", "r");

     while(1)

     {

        c = fgetc(fp1);

        if(c==EOF)

            break;

        else

            printf("%c", c);

     }

     fclose(fp1);

     return 0;

}

  1. In the program above which statement is functioning for opening a file
  2. Write the syntax for opening a file
  3. What mode that being used in the program. Give the example from the program
  4. Referring to the program above what has been stored in the pointer fp.
  5. Explain how to check whether the file has opened successfully?
  6. Write code that will check the file has opened successfully.
  7. Explain the function that can be used to read a file
  8. Explain how to write a file. Write C program to with the file.
  9. Explain the function used for closing a file.
  10. Write a program that contain open, read, write and close operation in C.
  11. How to read/write (i/o) strings in files?
  12. Write a program to read the strings from a file in C programming.

please answer all

In: Computer Science

(please use zelle's Python Graphics library, I've already asked this question and have had to post...

(please use zelle's Python Graphics library, I've
already asked this question and have had to post
this multiple times. I am working with the Python Graphics library and nothing else. thank you! note that I will downvote anything other than python graphics. this is the 4th time I've had to post this same question)
im trying to create a function that has a circle
bouncing left to right on a window and when the
circle is clicked on, it stops moving horizontally
and begins moving up and down on the window.

In: Computer Science

Using the following code write the following instructions in C++ Implementation: 1. Re-implement your String class...

Using the following code write the following instructions in C++

Implementation:

1. Re-implement your String class to use a dynamically allocated array for storage. It will be a NULL terminating charater array.

2. This dynamic version of the String will only allocate exactly the amount of memory necessary to store the characters. That is, the length will be the same as the capacity. However, the size of the dynamic array needs to have an extra char for the NULL terminator.

3. To re-write the constructors to allocate the correct amount of memory.

4. The default constructor allocates an array of size 1 for the empty string. The other constructors will allocate memory as needed. For example for String str("abc"); str.capacity() == 3, str.length() == 3, and str.string_size == 4.

5. Implement a destructor, copy constructor, constant time swap, and assignment operator for your ADT.

6. You will need to re-implement capacity(). length() remains the same.

7. You will also have to update concat and += to return the proper sized string result.

8. Implement the private constructors String(int) and String(int, const char *).
String(int) constructs the object as the emptry string with int capacity.
String(int, const char *) works the same as String(const char *) but allocates int capacity.

9. Implement a private method reset_capacity to change the capacity of your string while keeping the contents intact. That is, create a new array and copy contents over to the new array, making sure to clean up memory.

10. The private constructors and method may be useful for re-implementing + and +=.

Testing:

11. Write tests for the methods developed for this project.

12. Write test cases first. Testing must be thorough. You will be relying on the String to be correct.

13. You should make sure that the test cases you develop are very complete.

14. The otests test the constructors, assignment, copy, +, ==, and <.

15. If you add additional member variables the tests will not work properly.

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

string.hpp

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

#ifndef STRING_HPP
#define STRING_HPP

#include <iostream>

/**
 * @invariant str[length()] == 0
 *         && length()      == capacity()
 *         && capacity()    == stringSize - 1
 */
class String {
private:
    // helper constructors and methods
    String(int);
    String(int, const char *);
    void reset_capacity (int);

    char * str;

    // size includes NULL terminator
    int string_size;

public:

    // constructor: empty string, String('x'), and String("abcd")
    String();
    String(char);
    String(const char *);

    // copy ctor, destructor, constant time swap, and assignment
    String(const String &);
    ~String();
    void     swap          (String &);
    String & operator=     (String);

    // subscript: accessor/modifier and accessor
    char & operator[](int);
    char   operator[](int) const;

    // max chars that can be stored (not including null terminator)
    int capacity()      const;
    // number of char in string
    int length  ()      const;

    // concatenation
    String   operator+ (const String &) const;
    String & operator+=(String);

    // relational methods
    bool operator==(const String &)  const;
    bool operator< (const String &)  const;

    // i/o
    friend std::ostream& operator<<(std::ostream &, const String &);
    friend std::istream& operator>>(std::istream &, String &);

};

// free functios for concatenation and relational
String operator+       (const char *,   const String &);
String operator+       (char,           const String &);
bool   operator==      (const char *,   const String &);
bool   operator==      (char,           const String &);
bool   operator<       (const char *,   const String &);
bool   operator<       (char,           const String &);
bool   operator<=      (const String &, const String &);
bool   operator!=      (const String &, const String &);
bool   operator>=      (const String &, const String &);
bool   operator>       (const String &, const String &);

#endif

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

string.cpp

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

#include <iostream>
#include <cassert>
#include "string.hpp"

String::String(){
  str[0] = 0;
}

String::String(char ch){
  str[0] = ch;
  str[1] = 0;
}

String::String(const char* s){
  int pos = 0;
  while(s[pos] != 0){
    str[pos] = s[pos];
    ++pos;
        
    if(pos >= capacity()) break;
  }
  str[pos] = 0;
}

int String::length() const{
  int size = 0;
  while(str[size] != 0)
    ++size;
  return size;
        
}

int String::capacity() const{
  return STRING_SIZE -1;
}

char& String::operator[](int i){
  assert(i >= 0);
  assert(i <= length());
    
  return str[i];
}

void String::swap(String& str1){
  int tempStr = string_size;
  string_size = str1.string_size;
  str1.string_size = tempStr;

  int* tempStr1 = str;
  str = str1.str;
  str1.str = tempStr1;
}

char String::operator[](int i) const{
  assert(i >= 0);
  assert(i <= length());
    
  return str[i];
}

bool String::operator==(const String& rhs) const{
  int pos = 0;
  while(str[pos] != 0 && str[pos] == rhs.str[pos]){
    ++pos;
  }
  return str[pos] == rhs.str[pos];
}

std::istream& operator>>(std::istream& in, String& rhs){
  in >> rhs.str;
  return in;
}

std::ostream& operator<<(std::ostream& out, const String& rhs){
  out << rhs.str;
  return out;
}
        
bool String::operator<(const String& rhs) const{
  int pos = 0;
  while(str[pos] != 0 && rhs.str[pos] != 0 && str[pos] == rhs.str[pos]){
    ++pos;
  }
  return str[pos] < rhs.str[pos];
}

String String::operator+(const String& rhs) const{
  String result(str);
  int offset = length();
  int pos = 0;
    
  while(rhs.str[pos] != 0){
    result.str[offset + pos] = rhs.str[pos];
    ++pos;
  }
  result.str[offset + pos] = 0;
  return result;
}

String& String::operator+=(String rhs){
  int offset = length();
  int pos = 0;
    
  while(rhs.str[pos] != 0){
    if((offset + pos) >= capacity())
      break;
    str[offset + pos] = rhs.str[pos];
    ++pos;
  }
  str[offset + pos] = 0;
  return *this;
}

String operator+(const char charArray[], const String& rhs){
  return rhs + charArray;
}

String operator+(char s, const String& rhs){
  return s + rhs;
}

bool operator==(const char charArray[], const String& rhs){
  if(charArray == rhs){
    return true;
  }
  else{
    return false;
  }
}

bool operator==(char s, const String& rhs){
  if(s == rhs){
    return true;
  }
  else{
    return false;
  }
}

bool operator<(const char charArray[], const String& rhs){
  if(charArray < rhs){
    return true;
  }
  else{
    return false;
  }
}

bool operator<(char s, const String& rhs){
  if(s < rhs){
    return true;
  }
  else{
    return false;
  }
}

bool operator<=(const String& lhs, const String& rhs){
  if(lhs < rhs || lhs == rhs){
    return true;
  }
  else{
    return false;
  }
}

bool operator!=(const String& lhs, const String& rhs){
  if(lhs.length() != rhs.length()){
    return true;
  }
  int pos = 0;
  while(lhs[pos] != rhs[pos]){
    pos++;
  }
  if(pos == lhs.length()){
    return true;
    }
  return false;
}

bool operator>=(const String& lhs, const String& rhs){
  if(lhs > rhs || lhs == rhs) {
    return true;
  }
  else{
    return false;
  }
}

bool operator>(const String& lhs, const String& rhs){
  if(!(lhs <= rhs)){
    return true;
  }
  else{
    return false;
  }
}

In: Computer Science