Questions
In C++ First create the txt file given below. Then complete the main that is given....

In C++

First create the txt file given below. Then complete the main that is given. There are comments to help you. An output is also given You can assume that the file has numbers in it

Create this text file: data1.txt

-59 -33 34 0 69 24 -22 58 62 -36 
5 45 -19 -73 62 -5 95 42 

Main

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;

const int MAXSIZE = 100;

// Prototypes





int main()
{
    int nums[MAXSIZE];
    int searchFor;
    int indexFound = -1;
    int numElems;
    double average;
    string fileName;
    char again;

    do
    {

        cout << "Enter the file name: ";
        cin >> fileName;

        // Call the function fillArray. It has the fileName, the nums array and
        // the numElem passed in (in that order). It will calculate the numElems
        // Description of function given below



        // Call the function printArray. It has the nums array and
        // the numElem passed in (in that order). 
        // Description of function given below





        // Call the function findAverage. It has the nums array and
        // the numElem passed in (in that order). It stores the value
        // that is returned in the average variable declared above.
        // Description of function given below




        // Asks the user what number they want to search for
        cout << endl << endl;
        cout << "Enter a number between -100 and 100 to search for: ";
        cin >> searchFor;

        // Call the function findValue. It has the number being searched for
        // the nums array and the numElem passed in (in that order). 
        // It stores the index of the position in the array where the 
        // number was found in the indexFound variable declared above.
        // Description of function given below



        // Right the if statement to print whether the number was found.
        // If it was found, it will print the inde of where it was found.
        // (See output for what should be printed






        cout.setf(ios:: fixed);
        cout.precision(2);
        cout << "The average of all the numbers in the array is " << average << endl;
        cout << endl;
        cout << "Do you want to do this again? (Y/N): ";
        cin >> again;
    } while (toupper (again) == 'Y');
    return 0;
}



// Function: findValue
// This function has the value being serachedd for, the array and the number of 
// elements passed in. I searches the array and when it first finds it, it
// stops searching and returns the index of where it was found. If it is not 
// in the array, it returns a -1






// Function: findAverage
// This function has the array and the number of elements passed in.
// It computes the average of the numbers in the array and returns it.






// Function: printArray
// This function has the array and the number of elements passed in.
// It prints the array in neat columns, with 7 numbers per line







// Function: fillArray
// This function should open the file with the name that passed into it. If the file does
// not open correctly it should exit the program. It should
// then read in the numbers and load them into the array. 
// make sure you check that you don't exceed the array size.
// If the file has too many numbers, your program should not put the 
// extra numbers in the array, the array will just be full.
// This function determines the number of elements in the array.
// This function should not call any other user defined functions.

Sample Output

Enter the file name: data.txt
    -59    -33     34      0     69     24    -22
     58     62    -36      5     45    -19    -73
     62     -5     95     42

Enter a number between -100 and 100 to search for: 62
62 was found in index 8
The average of all the numbers in the array is 13.83

Do you want to do this again? (Y/N): Y
Enter the file name: data1.txt
    -59    -33     34      0     69     24    -22
     58     62    -36      5     45    -19    -73
     61     -9     95     42    -73    -64     91
    -96      2     53     -8     82    -79     16
     18     -5    -53     26     71     38    -31
     12    -33     -1    -65     -6      3    -89
     22     33    -27    -36     41     11    -47
    -32     47    -56    -38     57    -63    -41
     23     41     29     78     16    -65     90
    -58    -12      6    -60     42    -36    -52
    -54    -95    -10     29     70     50    -94
      1     93     48    -71    -77    -16     54
     56    -60     66     76     31      8     44
    -61    -74     23     37     38     18    -18
     29     41

Enter a number between -100 and 100 to search for: 52
The number 52 was not found in the array
The average of all the numbers in the array is 1.48

Do you want to do this again? (Y/N): y
Enter the file name: data.txt
    -59    -33     34      0     69     24    -22
     58     62    -36      5     45    -19    -73
     62     -5     95     42

Enter a number between -100 and 100 to search for: 95
95 was found in index 16
The average of all the numbers in the array is 13.83

Do you want to do this again? (Y/N): n

In: Computer Science

In python language do thee following: Some password scheme is designed such that the password must...

In python language do thee following:

Some password scheme is designed such that the password must start with a special symbol in “$” “@” or “!” followed by four letters that could be in a..z followed by a similar special symbol followed by three letters in A..Z followed by a single digit. Write a program that takes from the user a string, and verifies whether the string abides by this password scheme. Do this once using regular expressions. Another time without using regular expressions.

In: Computer Science

1) Describe the performance impact of using the LIKE operation with a wild card character at...

1) Describe the performance impact of using the LIKE operation with a wild card character at the beginning of the value.

2) Under what circumstances is a non-matching index scan performed?

3) A query is written to access a single table. Furthermore, that query will return only a single row because an equality predicate is coded on the primary key for the table. A unique index exists to support the primary key. What type of access is likely to be the most efficient for that query?

4) How can stored procedures be used to optimize performance in a client/server application?

5) Under what circumstances will a table scan outperform indexed access?

In: Computer Science

Programming Language: C++ Create a base class called Shape which has 2 attributes: X and Y...

Programming Language: C++

Create a base class called Shape which has 2 attributes: X and Y (positions on a Cartesian coordinate system). Since a shape is amorphous, set the class up so that an object of type Shape can not be instantiated.

Create three derived classes of your choice whose base class is Shape. These derived classes should have accessors/mutators for their class specific attributes, as well as methods to compute the area and the perimeter of the shape.

In main(), create a stack of pointers to Shape and push one object of each derived class onto the stack. Then, pop each shape pointer off of the stack and output that shape's area and perimeter, demonstrating polymorphism.

In: Computer Science

Clarify the differences between the types of location sensors built-in to the mobile device. And how...

Clarify the differences between the types of location sensors built-in to the mobile device. And how the Location information is accessed within an app?

In: Computer Science

I need a good pseudocode for C++ for a tic tac toe program.

I need a good pseudocode for C++ for a tic tac toe program.

In: Computer Science

Python Without running / testing the following code, predict what the following program prints on the...

Python

Without running / testing the following code, predict what the following program prints on the screen.

freeze = int(32)

boil = int(212)

freeze = 0

boil = 100

print(freeze, boil)

  • Write a program that asks the user for a number in the range of 1 through 7. The program should display the corresponding day of the week, where 1 = Monday, 2 = Tuesday and so forth. If the user types in a 6 then "Saturday" should be printed on the screen.
  • The program should display an error message if the user enters a number that is outside the range of 1 through 7.
  • Name the source code file
  • Test and run the program. Capture the output console and save it as an image file

In: Computer Science

in C++, given a binary search tree of ints, in which each node contains a size...

in C++, given a binary search tree of ints, in which each node contains a size parameter (also an int), explain, in English, not code, how you would find the median element of the tree in theta(log N) time.

In: Computer Science

Explain, If a device is configured with bandwidth and duplex settings on automatic, does the device...

Explain, If a device is configured with bandwidth and duplex settings on automatic, does the device at the other end of the connection have to be set to automatic as well?Explain, If a device is configured with bandwidth and duplex settings on automatic, does the device at the other end of the connection have to be set to automatic as well?

In: Computer Science

Create a script that take a directory path from the user. What I want you to...

Create a script that take a directory path from the user. What I want you to do is figure out the total size of all files in the directory. You will need to import the os module for this.

  • dirs=os.listdir(DIRECTORY) where DIRECTORY is the direction you want to look at will return a list of all files in that directory.
  • You can then use a for loop to go through dirs much like you went through a range in the previous examples you saw. Start by doing this and printing out the name of each file found.
  • Once you have that working create a total variable and use os.path.getsize(FILE) where FILE is the file's size you want to add the file size to total.
  • Print out the total size for all files in the directory. Note that the result is in bytes.
  • Use an if statement to print the total out in KB if the total is over 1024. If it is not, simply print the total in bytes.
  • Finally add to your program to also calculate the average size of a file in the given directory.

In: Computer Science

Develop a simple GUI-based Java program that may be used to control a lighting system

Develop a simple GUI-based Java program that may be used to control a lighting system

In: Computer Science

Develop code in a Scala Maven project to monitor a folder in HDFS in real time...

Develop code in a Scala Maven project to monitor a folder in HDFS in real time such that any new file in the folder will be processed .For each RDD in the stream, the following subtasks are performed concurrently: (a) Count the word frequency and save the output in HDFS. Note, for each word, make sure space (" "), comma (","), semicolon (";"), colon (":"), period ("."), apostrophe (“’”), quotation marks (“””), exclamation (“!”), question mark (“?”), and brackets ("[", “{”, “(”, “” ) are trimmed. (b) Filter out the short words (i.e., < 5 characters) and save the output in HDFS. (c) Count the co-occurrence of words in each RDD where the context is the same line; and save the output in HDFS.

In: Computer Science

(e) T F The set of all NP-hard problems is the same as the set of...

(e) T F The set of all NP-hard problems is the same as the set of all NP-complete problems.

(f) T F The dynamic programming technique can be used to solve any optimization problem.

(g) T F If A ≤p B and A is NP-Complete, then B is also NP-Complete.

(h) T F If a problem is in P, then it can be solved in polynomial time nondeterministically

with brief explaination

In: Computer Science

VBA question, write a function check keyword in a string. Question: Function sentimentCalc(tweet As String) As...

VBA question, write a function check keyword in a string.

Question:

Function sentimentCalc(tweet As String) As Integer

This function should check each word in the tweet and if the word exists as one of the keywords in the positive list or negative list it should impact the overall sentiment value. The positive list and negative list words exist in the keywords sheet. Access the keywords as ranges within your VBA code. The case of the word is inconsequential. For instance, happy, HAPPY, or hApPy are all treated as positive words regardless of their case (Hint: StrComp).

We have a keyword excel show that which word is positive and which is negative. How to get the keyword please see the hit part below.

If the word is in the positive list, it should increase the sentiment value by 10, if it is in the negative list it should decrease it by 10.

For instance, if the positive list includes “happy”, “rally”, “growth” and the negative list includes “crash”, “scam”, “bad” then:

If the Tweet is “I am Happy that Bitcoin is showing growth.”. The sentiment value will be 10 + 10 = 20

If the Tweet is “I am happy that Bitcoin is a scam and will CRASH!” The sentiment value will be 10 – 10 – 10 = -10

You must remove the following punctuation characters from the tweet text in your VBA code before calculating the sentiment: ! . , ? : ) ( ;

You may do this using multiple lines each calling the Replace function or with an array, loop and one call to the Replace function. Both methods will be marked as correct.

HIT:

You will need to use the string functions StrCom p, Split and Replace In this function.To get the ranges from the keywords Sheet use Worksheet and Range object like so:

Dim positive As Range

Set positive = Worksheets("keywords").Range("A2:A76")

Dim negative As Range

Set negative = Worksheets("keywords").Range("B2:B76")

This will give you the range A2:A76.From the sheet namedkeywords As the variable named positive.You can do the same for the negative range (but with different cell references And variable names).

You will need to use nested loops. One to go through each word in the keywords and one to Go through each word in the tweet text.

In: Computer Science

java code for scheduling problem (start time,end time , profite) using greedy algorithm

java code for scheduling problem (start time,end time , profite) using greedy algorithm

In: Computer Science