Questions
Based on your reading(learning) style, how could you have learned material better, how could you apply...

Based on your reading(learning) style, how could you have learned material better, how could you apply this information? Give an example of how you did or could have applied this information. 250 word initial response.

In: Psychology

C programing. Ask user to enter a word on sting and print all possible combinations. (please...

C programing.
Ask user to enter a word on sting and print all possible combinations. (please don't use printer) Using recursion.
example
ask user to input
user: "ABC"
output:
ABC
ACB
BAC
BCA
CAB
CBA

In: Computer Science

In Java, please create a new Java application called "CheckString" (without the quotation marks) according to...

In Java, please create a new Java application called "CheckString" (without the quotation marks) according to the following guidelines.

** Each method below, including main, should handle (catch) any Exceptions that are thrown. ** ** If an Exception is thrown and caught, print the Exception's message to the command line. **

  1. Write a complete Java method called checkWord that takes a String parameter called word, returns nothing, and is declared to throw an Exception of type Exception. In the method, check if the first character of the parameter is a letter. If it is not a letter, the method throws an Exception of type Exception with the message of: "This is not a word."
  2. Write a complete Java method called getWord that takes no parameters and returns a String. The method prompts the user for a word, and then calls the checkWord method you wrote in #1 above, passing as a parameter the word the user provided as input. Make sure the getWord method handles the Exception that may be thrown by checkWord.
  3. Write a complete Java method called writeFile that takes two parameters: an array of Strings (arrayToWrite) and a String (filename). The method writes the Strings in the arrayToWrite array to a text file called filename (the parameter), with each String on a separate line.
  4. Write a complete Java method called readFile that takes a String as a parameter (filename) and returns an ArrayList of Strings (fileContents). The method reads the text file identified by the filename parameter and populates the ArrayList with an element for each line in the text file.
  5. In your main method, do the following in the order specified:
    1. Call the getWord method you wrote in #2 above and print the result to the command line.
    2. Create an array of Strings called testData and populate it with at least three elements.
    3. Call the writeFile method you wrote in #3 above passing the array you created in #5.2 and the String "data.txt".
    4. Call the readFile method you wrote in #4 above to read the file you wrote in #5.3. Assign the result of readFile to an ArrayList variable in main called fileContents.
    5. Write a loop to print the contents of the fileContents ArrayList to the command line.

In: Computer Science

You have been hired by a home security company to design and implement a home alarm...

You have been hired by a home security company to design and implement a home alarm system. The logic of the system is as follows: once the alarm system has been armed, it is to sound if the front door is opened, the back door is opened or either of two windows is opened (you can assume there are only two windows).

Design the necessary circuit to implement the situation described above. Your circuit should have five inputs (A = alarm, F = front door, B = back door, W1 = window 1 and W2 = window 2). A = 1 means the system is armed; A = 0 means it is disarmed. F = 1 means the front door is open; F = 0 means it is closed. (Similarly for the back door and the windows.) There should be one output, S. When S = 1 the alarm should sound; S = 0 means the alarm is silent. Please use these letters to indicate the inputs and the output so all projects are consistent.

Be CAREFUL to get the correct function for your five inputs before simplifying and designing the circuit. You should minimize the circuit. Your inputs and output should be labeled. You should submit a Microsoft Word document including the following items while ensuring that everything is laid out in a manner that is easy to follow (portrait or landscape is acceptable):

• Your name in the top left

• Drawing of your completed circuit including all appropriate labels.

You will need to practice your MS Word drawing, layering, and object management skills.

See below for common logic gate objects that can be reused in your document.

• Truth tables for the circuit (use Word table feature)

• Kmap for the circuit (use Word table feature)

• Details (show your work) on what was done to simplify the circuit

• A brief written summary (250 to 500 words) of the process you followed, decisions made in laying out the circuit, etc..

In: Computer Science

Task 2: Debugging and writing functions In IDLE, use the File -> New Window menu option...

Task 2: Debugging and writing functions

  1. In IDLE, use the File -> New Window menu option to open a new editor window for your program, and save it using the name hw4Task2.py. Make sure to specify the .py extension.
  2. Copy the following (buggy) code into that file:

def mysum(x, y)

""" takes two numbers and returns their sum """

    total = x + y

    print(total)

  1. Save the file using Ctrl-S. Then try to run it using F5. What happens?
  2. This function includes two syntax errors – errors that violate the rules of the Python language. See if you can find and fix them, continuing until you are able to run the file without any error messages. (Create a MS Word file and name it Task2 stepsā€. Use this word file, to write what you did to fix the errors in this step.)
  3. Once you have eliminated the syntax errors, test the function from the Shell as follows:

>>> mysum(44, 67)

>>> print(mysum(10, 7))

What happens? Why?

(Use the MS Word file ā€œTask2 stepsā€, and write your answer to this step.)

  1. Fix the function so that both above tests work as expected.  (Use the MS Word file ā€œTask2 stepsā€ and write what you did in this step.)
  2. In hw4Task2.py, write a function named sum_double that accepts two integers as parameters. The function should return the sum of the integers, unless the two values are the same, in which case the function should return double their sum. For example:

                 >>> sum_double(1, 2)

                 3

                 >>> sum_double(3, 2)

                 5

                 >>> sum_double(2, 2)

                 8

Be sure to write a docstring for the function.

After writing the function, test it in two ways:

  • Make function calls from the Shell like the ones shown above.
  • Copy the following code into your file:

def test():

    """ function for testing """

    test1 = sum_double(1, 2)

    print('first test returns', test1)

    # Add more tests below

This code provides the beginnings of a test function, with lines that call the function with a set of inputs and print the return value. It’s worth noting that this function does not need a return statement, because its sole purpose is to make test calls and print their results.

You should:

  • add other test cases to the test function
  • run the Python file
  • call the test function from the Shell (by entering the call test()) and check that you obtain the correct return values for each test case.

(Use the MS Word file ā€œTask2 stepsā€and write what you did in this step.)

In: Computer Science

Write a Python program that will process the text file, Gettysburg.txt, by calculating the total words...

Write a Python program that will process the text file, Gettysburg.txt, by calculating the total words and output the number of occurrences of each word in the file.

The program needs to open the file and process each line. You need to add each word to the dictionary with a frequency of 1 or update the word’s count by 1. You need to print the output from high to low frequency.

The program needs 4 functions.

The first function is called add_word where you add each word to the dictionary. The parameters are the word and a dictionary. There is no return value.

The second function is called Process_line where you strip off various characters, split out the words, and so on. The parameters are a line and a dictionary. It calls the add_word function with each processed word. There is no return value.

The third function is called Pretty_print where this will be the printing function. The parameter is a dictionary. There is no return value.

The fourth function is the main where it will open the file and call Process_line on each line. When finished, it will call the Pretty_print function to print the dictionary.

Gettysburg.txt

Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this.

But, in a larger sense, we can not dedicate -- we can not consecrate -- we can not hallow -- this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us -- that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion -- that we here highly resolve that these dead shall not have died in vain -- that this nation, under God, shall have a new birth of freedom -- and that government of the people, by the people, for the people, shall not perish from the earth.

Abraham Lincoln
November 19, 1863

In: Computer Science

Carefully Read the Case study and answer both questions in 250 words each. Shades of meaning...

Carefully Read the Case study and answer both questions in 250 words each.

Shades of meaning

If you have tried the activities in the previous parts, you are likely to be appreciating afresh just how much is going on around our words as we use them to communicate.

As poet T.S. Eliot says, ā€œWords... slip, slide, perish, Decay with imprecision, will not stay in place, Will not stay still.ā€ Surely, our words have made it possible for us to construct our knowledge. But what meanings do they attempt to fix in place, and what meanings are they given by the millions of others who might read and interpret them? Our languages are, beyond doubt, an amazing way of knowing in enabling us to share knowledge. But how do we manage such sharing with words that ā€˜decay with imprecision’?

We do make various attempts to pin down and hold in place the core meanings of our words, prime among them being the move we take to define our terms. If we want to make sure that we are all talking about the same thing when we exchange ideas, we check our basic understanding. Many a discussion has reached a frustrating conclusion because the speakers never did figure out that they were entering with different understandings of a core concept, a central word. Witness social debates on ā€˜poverty’ and ā€˜development’ – let alone ā€˜the economy’ or ā€˜freedom’ or ā€˜war’. When a simple word such as ā€˜rock’ can slide around as we operate with it, what slippery territory we enter when we want to talk about the larger concepts that shape our understanding of the world!

When we define our terms, we are trying to use the symbols of our language to make another specific symbol precise. Definitions are statements within the system of symbols, rather like moves in a large language game, with each piece depending upon the others. We call the core definitional meaning the ā€˜denotation’ of the word, or in cases of multiple core meanings (ā€˜rock’ is a noun or a verb, with unlike meanings), the ā€˜denotations’.

We call the overtones of meaning, the nuances that arise as we use the word in particular contexts, its ā€˜connotations’. It is the connotations of a word that give it its ā€˜flavour’ or its ā€˜halo’ of meaning.

How we deal with the ambiguity of language – its imprecision in meaning and its connotations – depends on what the nature of our communication is and the kind of knowledge we are exchanging.

In some fields, precision is crucial. The sciences take care to define terms tightly in order to use exactly the right word, or leave language behind and instead opt in favour of using numbers or other sets of symbols. In other fields, finding exactly the right word may depend on deliberately using the ambiguity. Diplomacy and negotiation, for example, sometimes depend on indirection and subtle suggestion, and literature often depends for its expressive power on language whose connotations stir subjective associations of meaning. In yet other areas of our lives, we may not even care much about what the words we are using actually mean, since the communication of friendly chat is carried largely by the tone and accompanying body movement, and simply by the fact that we are making mouth noise companionably together. Altogether, the kind of knowledge we want to communicate affects our expectations of language and the ways we use it.

The Dictionary

1 What is the role of a dictionary? Is it descriptive, recording the changes in language as they happen? Or is it prescriptive, legislating what changes in language are acceptable?

2 In language, new words and usages are generated almost constantly, in response to changing need and creative impulse. Why do you think that some languages (French, Spanish, Icelandic) have official institutes which regulate what new ones are accepted? What are the arguments for and against preserving a language in a particular form?

In: Operations Management

Hello, I need to divide my code in this different parts. Use a standard approach to...

Hello, I need to divide my code in this different parts.

Use a standard approach to source files in this assignment: a .cpp for each function (you have at least two – main and ageCalc) a header file for the student struct, properly guarded

Code:

#include <iostream>

#include <string>

#include <fstream>

#include <algorithm>

#include <vector>

#include <iomanip>

using namespace std;

#define nullptr NULL

#define MAX_SIZE 100

struct Student

{

    string firstName;

    char middleName;

    string lastName;

    char collegeCode;

    int locCode;

    int seqCode;

    int age;

};

struct sort_by_age

{

    inline bool operator()(const Student *s1, const Student *s2)

    {

        return (s1->age < s2->age);

    }

};

int ageCalc(Student *studs[], Student *&youngest);

int main()

{

    Student *students[MAX_SIZE] = {nullptr};

    ifstream Myfile;

    Myfile.open("a2data.txt");

    if (!Myfile.is_open())

    {

        cout << "Could not open the file!";

        return 1;

    }

    vector<string> words;

    string line;

    while (!Myfile.eof())

    {

        getline(Myfile, line);

        line.c_str();

        int i = 0;

        string word = "";

        while (line[i] != '\0')

        {

            if (line[i] != ' ')

            {

                word = word + line[i];

                i++;

            }

            else

            {

                if (word != "")

                    words.push_back(word);

                word = "";

                i++;

            }

        }

        words.push_back(word);

    }

    Myfile.close();

    int count = 0;

    string fname = words.at(count);

    count++;

    int n = 0;

    while (count < words.size() - 2)

    {

        Student *s = new Student;

        s->firstName = fname;

        string mname = words.at(count);

        s->middleName = mname[0];

        count++;

        s->lastName = words.at(count);

        if (words.at(count).size() >= 12)

        {

            if (words.at(count)[1] >= '0' && words.at(count)[1] <= '9')

            {

                count--;

                s->middleName = ' ';

                s->lastName = words.at(count);

            }

        }

        count++;

        string id = words.at(count);

        count++;

        s->collegeCode = id[0];

        string loc = "";

        loc = loc + id[1];

        loc = loc + id[2];

        s->locCode = stoi(loc);

        string seq = "";

        for (int j = 3; j < 9; j++)

        {

            seq = seq + id[j];

        }

        s->seqCode = stoi(seq);

        string age = "";

        age = age + id[9];

        age = age + id[10];

        age = age + id[11];

        s->age = stoi(age);

        fname = id.erase(0, 12);

        students[n] = s;

        n++;

    }

    words.clear();

    sort(students, students + n, sort_by_age());

    cout << setw(15) << left << "Last Name";

    cout << setw(15) << left << "Midlle Name";

    cout << setw(15) << left << "First Name";

    cout << setw(15) << left << "College Code";

    cout << setw(12) << left << "Location";

    cout << setw(12) << left << "Sequence";

    cout << setw(12) << left << "Age" << endl;

    cout << "=======================================================================================" << endl;

    for (int i = 0; i < n; i++)

    {

        cout << setw(15) << left << students[i]->lastName;

        cout << setw(15) << left << students[i]->middleName;

        cout << setw(20) << left << students[i]->firstName;

        cout << setw(13) << left << students[i]->collegeCode;

        cout << setw(10) << left << students[i]->locCode;

        cout << setw(12) << left << students[i]->seqCode;

        cout << students[i]->age << endl;

    }

    cout << endl;

    Student *youngest = NULL;

    int avg_age = ageCalc(students, youngest);

    cout << "Average age is: " << avg_age << endl;

    cout << "Youngest student is " << youngest->firstName << " " << youngest->middleName << " " << youngest->lastName << endl;

    return 0;

}

int ageCalc(Student *studs[], Student *&youngest)

{

    youngest = studs[0];

    int i = 0;

    int avg_age = 0;

    while (studs[i] != NULL)

    {

        avg_age += studs[i]->age;

        if (youngest->age > studs[i]->age)

            youngest = studs[i];

        i++;

    }

    return avg_age / i;

}

File needed:

https://drive.google.com/file/d/15_CxuGnFdnyIj6zhSC11oSgKEYrosHck/view?usp=sharing

In: Computer Science

Hello, I need to divide my code in this different parts. Use a standard approach to...

Hello, I need to divide my code in this different parts.

Use a standard approach to source files in this assignment: a .cpp for each function (you have at least two – main and ageCalc) a header file for the student struct, properly guarded

Code:

#include <iostream>

#include <string>

#include <fstream>

#include <algorithm>

#include <vector>

#include <iomanip>

using namespace std;

#define nullptr NULL

#define MAX_SIZE 100

struct Student

{

    string firstName;

    char middleName;

    string lastName;

    char collegeCode;

    int locCode;

    int seqCode;

    int age;

};

struct sort_by_age

{

    inline bool operator()(const Student *s1, const Student *s2)

    {

        return (s1->age < s2->age);

    }

};

int ageCalc(Student *studs[], Student *&youngest);

int main()

{

    Student *students[MAX_SIZE] = {nullptr};

    ifstream Myfile;

    Myfile.open("a2data.txt");

    if (!Myfile.is_open())

    {

        cout << "Could not open the file!";

        return 1;

    }

    vector<string> words;

    string line;

    while (!Myfile.eof())

    {

        getline(Myfile, line);

        line.c_str();

        int i = 0;

        string word = "";

        while (line[i] != '\0')

        {

            if (line[i] != ' ')

            {

                word = word + line[i];

                i++;

            }

            else

            {

                if (word != "")

                    words.push_back(word);

                word = "";

                i++;

            }

        }

        words.push_back(word);

    }

    Myfile.close();

    int count = 0;

    string fname = words.at(count);

    count++;

    int n = 0;

    while (count < words.size() - 2)

    {

        Student *s = new Student;

        s->firstName = fname;

        string mname = words.at(count);

        s->middleName = mname[0];

        count++;

        s->lastName = words.at(count);

        if (words.at(count).size() >= 12)

        {

            if (words.at(count)[1] >= '0' && words.at(count)[1] <= '9')

            {

                count--;

                s->middleName = ' ';

                s->lastName = words.at(count);

            }

        }

        count++;

        string id = words.at(count);

        count++;

        s->collegeCode = id[0];

        string loc = "";

        loc = loc + id[1];

        loc = loc + id[2];

        s->locCode = stoi(loc);

        string seq = "";

        for (int j = 3; j < 9; j++)

        {

            seq = seq + id[j];

        }

        s->seqCode = stoi(seq);

        string age = "";

        age = age + id[9];

        age = age + id[10];

        age = age + id[11];

        s->age = stoi(age);

        fname = id.erase(0, 12);

        students[n] = s;

        n++;

    }

    words.clear();

    sort(students, students + n, sort_by_age());

    cout << setw(15) << left << "Last Name";

    cout << setw(15) << left << "Midlle Name";

    cout << setw(15) << left << "First Name";

    cout << setw(15) << left << "College Code";

    cout << setw(12) << left << "Location";

    cout << setw(12) << left << "Sequence";

    cout << setw(12) << left << "Age" << endl;

    cout << "=======================================================================================" << endl;

    for (int i = 0; i < n; i++)

    {

        cout << setw(15) << left << students[i]->lastName;

        cout << setw(15) << left << students[i]->middleName;

        cout << setw(20) << left << students[i]->firstName;

        cout << setw(13) << left << students[i]->collegeCode;

        cout << setw(10) << left << students[i]->locCode;

        cout << setw(12) << left << students[i]->seqCode;

        cout << students[i]->age << endl;

    }

    cout << endl;

    Student *youngest = NULL;

    int avg_age = ageCalc(students, youngest);

    cout << "Average age is: " << avg_age << endl;

    cout << "Youngest student is " << youngest->firstName << " " << youngest->middleName << " " << youngest->lastName << endl;

    return 0;

}

int ageCalc(Student *studs[], Student *&youngest)

{

    youngest = studs[0];

    int i = 0;

    int avg_age = 0;

    while (studs[i] != NULL)

    {

        avg_age += studs[i]->age;

        if (youngest->age > studs[i]->age)

            youngest = studs[i];

        i++;

    }

    return avg_age / i;

}

File needed:

https://drive.google.com/file/d/15_CxuGnFdnyIj6zhSC11oSgKEYrosHck/view?usp=sharing

In: Computer Science

Hello, I need to divide my code in this different parts. Use a standard approach to...

Hello, I need to divide my code in this different parts.

Use a standard approach to source files in this assignment: a .cpp for each function (you have at least two – main and ageCalc) a header file for the student struct, properly guarded

Code:

#include <iostream>

#include <string>

#include <fstream>

#include <algorithm>

#include <vector>

#include <iomanip>

using namespace std;

#define nullptr NULL

#define MAX_SIZE 100

struct Student

{

    string firstName;

    char middleName;

    string lastName;

    char collegeCode;

    int locCode;

    int seqCode;

    int age;

};

struct sort_by_age

{

    inline bool operator()(const Student *s1, const Student *s2)

    {

        return (s1->age < s2->age);

    }

};

int ageCalc(Student *studs[], Student *&youngest);

int main()

{

    Student *students[MAX_SIZE] = {nullptr};

    ifstream Myfile;

    Myfile.open("a2data.txt");

    if (!Myfile.is_open())

    {

        cout << "Could not open the file!";

        return 1;

    }

    vector<string> words;

    string line;

    while (!Myfile.eof())

    {

        getline(Myfile, line);

        line.c_str();

        int i = 0;

        string word = "";

        while (line[i] != '\0')

        {

            if (line[i] != ' ')

            {

                word = word + line[i];

                i++;

            }

            else

            {

                if (word != "")

                    words.push_back(word);

                word = "";

                i++;

            }

        }

        words.push_back(word);

    }

    Myfile.close();

    int count = 0;

    string fname = words.at(count);

    count++;

    int n = 0;

    while (count < words.size() - 2)

    {

        Student *s = new Student;

        s->firstName = fname;

        string mname = words.at(count);

        s->middleName = mname[0];

        count++;

        s->lastName = words.at(count);

        if (words.at(count).size() >= 12)

        {

            if (words.at(count)[1] >= '0' && words.at(count)[1] <= '9')

            {

                count--;

                s->middleName = ' ';

                s->lastName = words.at(count);

            }

        }

        count++;

        string id = words.at(count);

        count++;

        s->collegeCode = id[0];

        string loc = "";

        loc = loc + id[1];

        loc = loc + id[2];

        s->locCode = stoi(loc);

        string seq = "";

        for (int j = 3; j < 9; j++)

        {

            seq = seq + id[j];

        }

        s->seqCode = stoi(seq);

        string age = "";

        age = age + id[9];

        age = age + id[10];

        age = age + id[11];

        s->age = stoi(age);

        fname = id.erase(0, 12);

        students[n] = s;

        n++;

    }

    words.clear();

    sort(students, students + n, sort_by_age());

    cout << setw(15) << left << "Last Name";

    cout << setw(15) << left << "Midlle Name";

    cout << setw(15) << left << "First Name";

    cout << setw(15) << left << "College Code";

    cout << setw(12) << left << "Location";

    cout << setw(12) << left << "Sequence";

    cout << setw(12) << left << "Age" << endl;

    cout << "=======================================================================================" << endl;

    for (int i = 0; i < n; i++)

    {

        cout << setw(15) << left << students[i]->lastName;

        cout << setw(15) << left << students[i]->middleName;

        cout << setw(20) << left << students[i]->firstName;

        cout << setw(13) << left << students[i]->collegeCode;

        cout << setw(10) << left << students[i]->locCode;

        cout << setw(12) << left << students[i]->seqCode;

        cout << students[i]->age << endl;

    }

    cout << endl;

    Student *youngest = NULL;

    int avg_age = ageCalc(students, youngest);

    cout << "Average age is: " << avg_age << endl;

    cout << "Youngest student is " << youngest->firstName << " " << youngest->middleName << " " << youngest->lastName << endl;

    return 0;

}

int ageCalc(Student *studs[], Student *&youngest)

{

    youngest = studs[0];

    int i = 0;

    int avg_age = 0;

    while (studs[i] != NULL)

    {

        avg_age += studs[i]->age;

        if (youngest->age > studs[i]->age)

            youngest = studs[i];

        i++;

    }

    return avg_age / i;

}

File needed:

https://drive.google.com/file/d/15_CxuGnFdnyIj6zhSC11oSgKEYrosHck/view?usp=sharing

In: Computer Science