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 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 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.
**
In: Computer Science
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
def mysum(x, y)
""" takes two numbers and returns their sum """
total = x + y
print(total)
>>> mysum(44, 67)
>>> print(mysum(10, 7))
What happens? Why?
(Use the MS Word file āTask2 stepsā, and write your answer to this step.)
>>> 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:
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:
(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 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
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 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 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 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