Questions
1) How do you extract a part of a string? Give the command and examples (in...

1) How do you extract a part of a string? Give the command and examples (in arduino)

2) Explain how negation and comparison operators combine together. (in Arduino)

3) What are the qualifiers? (in Arduino)

4) List the increment and decrement operators. (in Arduino)

In: Computer Science

Flow this Code to answer question below #include <iostream> using std::cout; struct Node {     int...

Flow this Code to answer question below

#include <iostream>

using std::cout;

struct Node {

    int data;

    Node *link;

                 Node(int data=0, Node *p = nullptr) { //Note, this constructor combines both default and parameterized constructors. You may modify the contructor to your needs

        this->data = data;

                                  link = p;

    }

};

class linked_list

{

private:

    Node *head,*current;

public:

     //constructor

    linked_list() {

        head = nullptr;//the head pointer

        current = nullptr;//acts as the tail of the list

    }

    //destructor - IMPORTANT

    ~linked_list() {

                                  current = head;

                                  while( current != nullptr ) {//the loop stops when both current and head are NULL

                                  head = head->link;

                                  delete current;

                                  current = head;

                                  }

    }

    void addLast(int n) {// to add a node at the end of the list

        if(head == nullptr){

            head = new Node(n);

            current = head;

        } else {

                                                   if( current->link != nullptr)

                                                                    current = current->link;

            current->link = new Node(n);

            current = current->link;//You may decide whether to keep this line or not for the function

        }

    }

   

    void print() { // to display all nodes in the list

        Node *tmp = head;

        while (tmp != nullptr) {

            cout << tmp->data << std::endl;

            tmp = tmp->link;

        }

    }

};

int main() {

    linked_list a;

    a.addLast(1);

   a.addLast(2);

                 a.print();

   

    return 0;

}

Question:

Create the node structure and the linked list class. The sample class has implemented the following member methods:

o constructor

o destructor

o print(),

o addLast()

2. Implement the following member methods:

▪ addFirst (T data) // Adds a node with data at the beginning of the list

▪ pop() // Removes the first node of the list. Note: Don't forget to delete/reallocate the removed dynamic memory

▪ contains(T data) // Returns true or false if a node contains the data exists in the list

▪ update(T oldDate, T newData) // Updates the oldData of a node in the list with newData.

▪ size() // Returns the number of nodes in the list

▪ remove( T data) //Removes the node that contains the data. Note, you will need to check if the node exists. Again, don't forget to delete/re-allocate the dynamic memory

3. (Extra Credit Part) Implement the following additional member methods

▪ insertAfter(int n, T data) //Adds a node after the n-th node. Note, you will need to check if the n th node exists, if not, do addLast().

▪ merge(const LinkedList &linkedlist) //Merges this object with linkedlist object. In other words, add all nodes in linkedlist to this object.

In: Computer Science

create a program that asks the user’s height What is your height? Use the input function...

create a program that asks the user’s height

  1. What is your height? Use the input function to ask this question
  2. If the answer to question 1 is greater than or equal to five, print "Yay! You can get on the rides alone"
  3. If the answer to question 1 is less than five and greater than four, print "You must be accompanied by an adult"
  4. Otherwise, print "Sorry you’re not allowed on the rides"

In: Computer Science

For this task you will create a Point3D class to represent a point that has coordinates...

For this task you will create a Point3D class to represent a point that has coordinates in three dimensions labeled x, y and z. You will then use the class to perform some calculations on an array of these points. You need to draw a UML diagram for the class (Point3D) and then implement the class.
The Point3D class will have the following state and functionality:

  • Three data fields, x, y and z, of type double, represent the point’s coordinates
  • Additional data field, colour, of type String, represents the point's color
  • A no-arg constructor creates a point at position (0, 0, 0) and "Red" colour.
  • Another constructor creates a point with specified coordinates and colour.
  • A getter method is provided for each of the fields.
  • An accessor method named distance returns the distance between the current point and another point passed as an argument.
  • The distance method is overloaded to accept the coordinates of the other point.

Write a TestPoint3D class that will have a main method, and perhaps other methods as required by good design, to test your Point3D class. It will not have user input because this class will stand as a record of the tests you have applied and you will be able to run it whenever you alter your Point3D class. For the TestPoint3D class you will need to do the following:

  • Test the basic state and functionality of the Point3D class. Each of the constructors and each of the methods should be tested using some different data values. The test code should display values so that they can be checked.
  • Write some code to create an array of at least 10 Point3D objects.
  • Write a method max, which will accept the array of points as an argument, and will calculate and display the maximum distance between the points in the array, and the pair of points for which the maximum occurs.
  • Write a method min, which will accept the array of points as an argument, and will calculate and display the minimum distance between the points in the array, and the pair of points for which the minimum occurs.

In: Computer Science

Shapes2D Write the following four classes to practice using an abstract class and polymorphism. Submit all...

Shapes2D
Write the following four classes to practice using an abstract class and polymorphism. Submit all four classes.

Shape2D class
For this class, include just an abstract method name get2DArea() that returns a double.

Rectangle2D class
Make this class inherit from the Shape2D class. Have it store a length and a width as fields. Provide a constructor that takes two double arguments and uses them to set the fields. Note, the area of a rectangle is the length times the width.

Circle2D class
Also make this class inherit from the Shape2D class. Have it store a radius as a field. Provide a constructor that takes a double argument and uses it to set the field. Note, the area of a circle is PI times it's radius times it's radius.

Shape2DDriver class
Have this class provide a method named displayName() that takes an object from just any of the above three classes (you can't use an Object type parameter). Have the method display the area of the object, rounded to one decimal place.

In: Computer Science

PART A Write a C program that takes the names and surnames of the students and...

PART A

Write a C program that takes the names and surnames of the students and then displays the initial and last name of the name on the screen. For instance, if Onur Uslu is entered as input, the output of our program must be O. Uslu.

PART B

Write a C program that asks the user to enter a string and then sends it to a function that does the following job and shows the response from the function on the screen. The function must return all words in the string from the program by converting the initial letters into their large form.

Example Output

Type of a string:Hello world

New sentence:Hello World

In: Computer Science

Think of an algorithm to find the maximum value in an (unsorted) array. Now, think of...

Think of an algorithm to find the maximum value in an (unsorted) array. Now, think of an algorithm to find the second largest value in the array. Which is harder to implement? Which takes more time to run (as measured by the number of comparisons performed)? Now, think of an algorithm to find the third largest value. Finally, think of an algorithm to find the middle value. Which is the most difficult of these problems to solve?

In: Computer Science

Objective: Design and test a 4-bit Right shift register with serial input. Part I Use D...

Objective: Design and test a 4-bit Right shift register with serial input.

Part I

Use D flip-flops (FF) in your design (Memory → D Flip-Flop). Ensure the output of each FF (Q) goes to an output so the functionally of the shift register can be verified. All 4 Flip-Flop need to share a common clock which is connected to an input you can control. Verify the functionally of the circuit by changing the input value and toggling the clock. You should see the value in the register shift to the right.

Part II

Modify the circuit so that if the register contains 1010 OR 0111 an output signal goes active (logic 1). Verify the functionally of the circuit by shifting in the two values to be detected and ensure the output goes high (logic 1).

Please use some kind of software and attach screenshots

In: Computer Science

Briefly describe what each of the following statements does. file.seekp(100L, ios::beg); file.seekp(-10L, ios::end); file.seekg(-25L, ios::cur); file.seekg(30L,...

  1. Briefly describe what each of the following statements does.

file.seekp(100L, ios::beg);

file.seekp(-10L, ios::end);

file.seekg(-25L, ios::cur);

file.seekg(30L, ios::cur);

  1. Describe the mode that each of the following statements causes a file to be opened in.

file.open("info.dat", ios::in | ios::out);

file.open("info.dat", ios::in | ios::app);

file.open("info.dat", ios::in | ios::out | ios::ate);

file.open("info.dat", ios::in | ios::out | ios::binary);

In: Computer Science

Shapes2D Write the following four classes to practice using an abstract class and polymorphism. Submit all...

Shapes2D
Write the following four classes to practice using an abstract class and polymorphism. Submit all four classes.

Shape2D class
For this class, include just an abstract method name get2DArea() that returns a double.

Rectangle2D class
Make this class inherit from the Shape2D class. Have it store a length and a width as fields. Provide a constructor that takes two double arguments and uses them to set the fields. Note, the area of a rectangle is the length times the width.

Circle2D class
Also make this class inherit from the Shape2D class. Have it store a radius as a field. Provide a constructor that takes a double argument and uses it to set the field. Note, the area of a circle is PI times it's radius times it's radius.

Shape2DDriver class
Have this class provide a method named displayName() that takes an object from just any of the above three classes (you can't use an Object type parameter). Have the method display the area of the object, rounded to one decimal place.

Written in java

In: Computer Science

only the Java programInstructions: This project has three parts. Remember to make a copy of this...

only the Java programInstructions:

This project has three parts. Remember to make a copy of this project so you can refer to it when completing the other phases.

Review the sample program before starting this project. The sample program does not exactly match the requirements for this project, so some critical thinking will still be required; however, it is a good thing to reference before starting the project.

Project 2 is a continuation of Project 1. Modify the code from Project 1 in the following ways:

Step 1: Add code to prompt the user to enter the name of the room that they are entering information for.

Step 2: Add Input Validation to the code using the following rules:

  • The length of the room cannot be less than 5 feet
  • The width of the room cannot be less than 5 feet
  • The user's menu selection for the amount of shade should be 1, 2, or 3.

If the user's input is invalid, the program should display an appropriate error message and prompt the user to re-enter their input. The user should be given an unlimited amount of attempts to enter valid input

Step 3: Add code to have the program ask the user if they would like to enter information about another room after the information for a previous room has been processed and displayed. The user should be able to enter a "y" or "Y" to indicate that they want to enter information about another room. See the Sample Input and Output for how to format this.

Step 4: After the user has indicated that they do not wish to enter information about another room, the program should output the number of rooms that have been entered and then stop executing.

Sample Input and Output (user input is in bold) - The output of your program should match the formatting and spacing exactly as shown

Please enter the name of the room: Guest Bedroom
Please enter the length of the room (in feet): 15.5
Please enter the width of the room (in feet): 10
What is the amount of shade that this room receives?

  1. Little Shade
  2. Moderate Shade
  3. Abundant Shade

Please select from the options above: 3

Air Conditioning Window Unit Cooling Capacity

Room Name: Guest Bedroom
Room Area (in square feet): 155.0
Amount of Shade: Abundant
BTUs Per Hour needed: 4,950

Would you like to enter information for another room (Y/N)? Y

Please enter the name of the room: Kitchen
Please enter the length of the room (in feet): 20
Please enter the width of the room (in feet): 15
What is the amount of shade that this room receives?

  1. Little Shade
  2. Moderate Shade
  3. Abundant Shade

Please select from the options above: 2

Air Conditioning Window Unit Cooling Capacity

Room Name: Kitchen
Room Area (in square feet): 300.0
Amount of Shade: Moderate
BTUs Per Hour needed: 10,000

Would you like to enter information for another room (Y/N)? N

The total number of rooms processed was: 2

In: Computer Science

Write a c++ program that asks the user to choose his preferred shape, and asks then...

Write a c++ program that asks the user to choose his preferred shape, and asks then for two numbers (positive but not necessary integers) in order to calculate the shape's area.

The possible shapes are: Triangle, Ring and Rectangle. If the user chose a different shape, you

will warn him and wait for a valid shape.

  • The area of a circle is πr12-r22 (suppose π= 3.4 ).
  • The area of a triangle is base*height/2.
  • The area of a rectangle is height*width.

While the user will enter the values in cm , the program will display the number of paint bottles

needed to paint the area of the shape. Each bottle can cover 5cm^2. The number of paint bottles should be an integer value.

In: Computer Science

In 300 words or more, describe the advantages and concepts of a Chen ER diagram and...

In 300 words or more, describe the advantages and concepts of a Chen ER diagram and how the diagram will help shape the overall relationship between tables.

In: Computer Science

Write a C++ program that will take and validates from the user an integer n between...

Write a C++ program that will take and validates from the user an integer n between 1 and 4. The program will then continue by taking 5 characters from the user. The program will ask the user whether he needs to rotate the characters to the left or to the right. If the user enters a wrong answer, the program will do a rotation to the right. Depending on the answer, the program will rotate the characters "n" times and displays the result on the screen. The program should contain 2 loops. Example 1: The user will enter a value n=3, the characters A B C D E, and rotation to the left. The program will then display DEABC. Example 2: The user will enter a value n=3, the characters A B C D E, and rotation to the right. The program will then display CDEAB.

In: Computer Science

It is about C++linked list code. my assignment is making 1 function, in below circumstance,(some functions...

It is about C++linked list code. my assignment is making 1 function, in below circumstance,(some functions are suggested for easier procedure of making function.)

void pop_Stack (struct linked_list* list, int number) //*This is the function to make and below is the explanation that should be written in given code.

This function removes some nodes in stack manner; the tail of the list will be removed, repeatedly. The parameter (variable 'number') means the number of nodes that will be removed. When parameter is bigger than 1, popping a node with n times, you do not remove node at one go. If there is only one node in the list, please make sure it frees (de-allocates) both the node and the list. If the list is not a stack type(list->type_of_list!=1), print the error message “Function pop_Stack: The list type is not a stack” and exit the function. If the 'number' parameter is less than 1 or more than the number of nodes in the stack, respectively print the error message “Function popStack: The number of nodes which will be removed is more than 1” and “Function popStack: The number of nodes which will be removed is more than that in the stack”, then exit the function. The removed nodes should be freed.

Given code is written below,(There is a function to fill in last moment in this code)

linked_list.h: This is the header file of linkLQS.c that declares all the functions and values that are going to be used in linkLQS.c. You do not have to touch this function.

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

(Below code is about linked_list.h)

#include
#include
#include


struct linked_node{
   int value;
   struct linked_node* next;
   struct linked_node* prev;
};

struct linked_list{
   int type_of_list; // normal = 0, stack = 1
   struct linked_node* head;
   struct linked_node* tail;
   int number_of_nodes;
};

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

#include "linked_list.h"
#include "string.h"

int list_exist;

struct linked_list* create_list (int number_of_nodes, int list_type)
{
   int a[number_of_nodes];
   int i, j;
   int bFound;

   if (number_of_nodes < 1)
   {
       printf("Function create_list: the number of nodes is not specified correctly\n");
       return NULL;
   }
   if(list_exist == 1)
   {
       printf("Function create_list: a list already exists\nRestart a Program\n");
       exit(0);  
   }
   if(list_type != 0 && list_type != 1)
   {
       printf("Function create_list: the list type is wrong\n");
       exit(0);  
   }
   struct linked_list * new_list = (struct linked_list*)malloc(sizeof(struct linked_list));
   new_list->head = NULL;
   new_list->tail = NULL;
   new_list->number_of_nodes = 0;
   new_list->type_of_list = list_type;

   //now put nodes into the list with random numbers.
   srand((unsigned int)time(NULL));
   if(list_type == 0)
   {
       for ( i = 0; i < number_of_nodes; ++i )
       {
           while ( 1 )
           {
  
               a[i] = rand() % number_of_nodes + 1;
               bFound = 0;
               for ( j = 0; j < i; ++j )
               {
                   if ( a[j] == a[i] )
                   {
                       bFound = 1;
                       break;
                   }
               }
               if ( !bFound )
                   break;
           }
           struct linked_node* new_node = create_node(a[i]);
           insert_node(new_list, new_node);
       }
   }
   else if(list_type == 1)
   {
       for ( i = 0; i < number_of_nodes; ++i )
       {
           while ( 1 )
           {
  
               a[i] = rand() % number_of_nodes + 1;
               bFound = 0;
               for ( j = 0; j < i; ++j )
               {
                   if ( a[j] == a[i] )
                   {
                       bFound = 1;
                       break;
                   }
               }
               if ( !bFound )
                   break;
           }
           struct linked_node* new_node = create_node(a[i]);
           push_Stack(new_list, new_node);
       }
   }
   list_exist = 1;
   printf("List is created!\n");
   return new_list;
}

struct linked_node* create_node (int node_value)//This functon is the example for reference of the assignment function
{
   struct linked_node* node = (struct linked_node*)malloc(sizeof(struct linked_node));
   node->value = node_value;
   node->next = NULL;
   node->prev = NULL;
   return node;
}

void insert_node(struct linked_list* list, struct linked_node* node)//This functon is the example for reference of the assignment function
{
   node->next = NULL;
   node->prev = NULL;

   if(list->head == NULL)       //if head is NULL, tail is also NULL.
   {
       list->head = node;
       list->tail = node;
       list_exist = 1;
   }
   else if(list->head == list->tail)
   {
       node->next = list->head;
       list->head->prev = node;
       list->head = node;
   }
   else if(list->head != list->tail)
   {
       node->next = list->head;
       list->head->prev = node;
       list->head = node;
   }
   (list->number_of_nodes)++;
}

void pop_Stack(struct linked_list* list, int number)//The function to be written!!
{
~~~~~~~~~~~~~ //your code starts from here
}

In: Computer Science