Questions
Write a Python program that prompts the user to enter a list of words and stores...

Write a Python program that prompts the user to enter a list of words and stores in a list only those words whose first letter occurs again within the word (for example, 'Baboon'). The program should display the resulting list..................please explain step by step

In: Computer Science

wiki talk about this article in marketing with own you word Personal selling is one of...

wiki

talk about this article in marketing with own you word

Personal selling is one of the oldest forms of marketing communication; due to its effectiveness, it allows for targeting a specific message to a specific customer. However personal selling is not appropriate for every company or situation.

In: Operations Management

Why use parallelism? In a 500-word paper, define the ways of measuring speed of computers, and...

Why use parallelism? In a 500-word paper, define the ways of measuring speed of computers, and discuss how parallelism is used in super- computing. Include in your answer:


The ways we can measure speed.


Examples of super-computing and how it is being used.


In: Computer Science

Week 1 Write a 175- to 265-word response to the following questions: How is the landscape...

Week 1 Write a 175- to 265-word response to the following questions:

  • How is the landscape of health care changing today? As a manager, how can you address change?
  • Choose one current issue and provide an example of how you might deal with it.

In: Operations Management

For this assignment, you are required to write a MIPS program that reads its own instructions...

For this assignment, you are required to write a MIPS program that reads its own instructions and counts the number of occurrences of each type of instruction (R-type, I-type, or J-type). To accomplish this task, your program should execute the following steps:

  1. First, your program should load the address of its first instruction (0x400000) into a register, and initialize three separate instruction class counters to zero.
  2. Next, your program should enter a loop that reads each instruction from memory. For each instruction, examine the “op code” field to determine whether it is an R-type, I-type, or J-type instruction, and increment the appropriate instruction class counter. (For the purpose of this assignment, you may assume that all instructions with an op code of 0 are R-type instructions; all instructions with an op code equal to either 2 or 3 are J-type instructions; and all other instructions are I-type instructions.)
  3. Your source program’s final two instructions should be

       li           $v0, 10

       syscall

Thus, your program should repeat step 2’s loop until the machine instructions corresponding to this sequence are detected. (Be sure to count these machine instructions as well!)

  1. Finally, save the values of your instruction class counters to variables declared in the data segment of your program. (For testing purposes, I recommend also using syscalls to display the three integer counts to the screen; if you do, be careful not to halt on these additional syscall instructions.)

THE SOLUTION FOR THIS ASSIGNMENT IS ACTUALLY ON CHEGG, BUT IT DOESN'T WORK. CAN YOU PLEASE HELP ME TO FIX THE ISSUE?

.data

#Inst: .#

CountR: .word 0
CountJ: .word 0
CountI: .word 0

CountR_char : .asciiz "CountR is "
CountJ_char : .asciiz "\nCountJ is "
CountI_char : .asciiz "\nCountI is "

TypeR: .word 0x00 #should be something like this but I don't know what exactly it should be
TypeJ1: .word 0x02
TypeJ2: .word 0x03

EndI: .word 0x2402000A #last but one instruction as last instruction is syscall and not unique

#first instruction is stored in memory location 0x00400000
#and second instruction is stored in location 0x00400004 and so on.
#Every instruction's type(op code) is stored as bit 31-26 in that 32bit

.text

main:

   lw $t0, CountR
   lw $t1, CountJ
   lw $t2, CountI
   lw $t4, TypeR
   lw $t5, TypeJ1
   lw $t6, TypeJ2
   li $t3, 0x00400000 #starting address
   li $s0, 0 #instruction code
   lw $t7, EndI

Loop: #read instruction at address into $s0

   lw $s0,0($t3) #Load complete word and rotate by right by 26
   #shift it right logical by 2 ,makes it 00xxxx, $s0= bit 31-26
   srl $s0,$s0,26
   # check shifted instruction
   beq $s0, $t4, typeR #if it's typeR, then jump to typeR
   beq $s0, $t5, typeJ #if it's typeJ1, then jump to typeJ
   beq $s0, $t6, typeJ #if it's typeJ2, then jump to typeJ

TypeI: #none of above, then it's typeI

   addi $t2, $t2, 1 #countI +1
   j Next #jump to next

typeR: # bit (31-26) is 0x00 (type r)
   addi $t0, $t0, 1 #countR +1
   j Next #jump to next

typeJ: # bit (31-26) is 0x02 or 0x03
   addi $t1, $t1, 1 #countJ +1
   j Next #jump to next

Next: #after count, check if it's end instruction
   lw $s0,0($t3)
   beq $s0,$t7,Exit #if it's endI, jump to exit

#not end yet, add address to get another instruction
   addi $t3,$t3,4 #address+4
   j Loop

Exit: #one last syscall instruction is remaining that is Type R, increment CountR
   addi $t0, $t0, 1 #countR +1 for syscall
   # store the result
   sw $t0,CountR
   sw $t1,CountJ
   sw $t2,CountI

#print result

#----------

   li $v0,4 #string print
   la $a0, CountR_char
   syscall
   li $v0,1
   add $a0, $t0 ,$0

   syscall
   li $v0,4 #string print

   la $a0, CountJ_char
   syscall

    li $v0,1
   add $a0, $t1 ,$0
   syscall

   li $v0,4 #string print
   la $a0, CountI_char
   syscall

   li $v0,1
   add $a0, $t2 ,$0
   syscall


   li $v0,10
   syscall

In: Computer Science

Program Behavior Each time your program is run, it will prompt the user to enter the...

Program Behavior

Each time your program is run, it will prompt the user to enter the name of an input file to analyze. It will then read and analyze the contents of the input file, then print the results.

Here is a sample run of the program. User input is shown in red.

Let's analyze some text!
Enter file name: sample.txt
Number of lines: 21
Number of words: 184
Number of long words: 49
Number of sentences: 14
Number of capitalized words: 19

Make sure the output of your program conforms to this sample run. Of course, the values produced will be different depending on the input file being analyzed.

The sample input file that was used for this example can be downloaded from here. You can use it for testing your program, but you should also test it against other input files. To use a file for testing, just add it to the project folder.

The contents of that sample input file are:

This is a sample text file used as input for Project 2. It contains regular
English text in sentences and paragraphs that are analyzed by the program.

The program counts the number of lines in the input file, as well as the
total number of words. It also counts the number of long words in the file.
A word is considered long if it has more than five characters. The program
also counts the number of sentences by counting the number of periods in
the file.

Finally, the program counts the number of capitalized words in the input
file. It uses a separate method to determine if a word is capitalized.

Blank lines will count toward the line count, but do not contribute any
words.

This program uses Scanner objects in three ways. One Scanner object is used
to read the file name that the user types at the keyboard. Another Scanner
is used to read each line in the file, and the third is used to parse the
individual words on the line.

This concludes this sample input file. Have a nice day.

Program Design

Create a new BlueJ project called Project2 and inside that create a class called TextAnalyzer. Add a static method called analyze. which will do most of the process for this program. The header of the method should look like this:

public static void analyze() throws IOException

Notice the addition of the throws keyword. This simply tells the compiler that the code inside the method might cause a run-time error of type IOException. This will happen in the case when you enter a file name that doesn't exist inside the project's folder. Using the throws keyword, you are delegating the responsibility of handling this IO (Input Output) run-time error to the caller of the method so you don't need to handle an error like this in your code.

Use three different Scanner objects to accomplish this program. One will read the name of the input file from the user, another will read each line of the input file, and the third will be used to parse each line into separate words.

Determine the appropriate places in your program to count the following:

  • lines - each line in the input file (terminated by the end-of-line character)
  • words - any text separated by white space
  • long words - any word longer than 5 characters
  • sentences - an English sentence that ends in a period. The last word in a sentence will contain a period (search for the appropriate method to use in the String API (Links to an external site.). )
  • capitalized words - any word that begins with an uppercase alphabetic character

For the purposes of our analysis, a word is defined as any set of continuous characters separated by white space (spaces, tabs, or new line characters). Punctuation will get caught up in the words. For example, in the sample input file "Finally," is a considered a single word, including the comma. Likewise, "2." and "ways." are words.

The sentence count is really just a count of the periods in the input file. Or, more precisely for your program, it is the count of the number of words that contain a period. Notice the difference between counting lines and counting sentences.

You will define a second, separate method to help analyze capitalized words. Write a method called wordIsCapitalized that accepts a String parameter representing a single word and returns a boolean result. Return true if the first character of the word is an uppercase alphabetic character and false otherwise. Fortunately, there is a method called isUpperCase already defined in the Character class of the Java API that can help with this.

Developing the Program

As always: work on your solution in stages. Don't try to get the whole thing written before compiling and testing it. Suggestions:

  • Get the infrastructure of the program set up, printing just the intro line and the first prompt. Compile and run the program.
  • Set up the Scanner object for reading the input file name. Read the file name and print it back out temporarily. Compile and test.
  • Now set up the second Scanner object to read from the input file. Write the loop to read each line of the input file and print it back out. Again, this is temporary output just to prove to yourself that you're reading the file correctly. Then you can move forward with confidence that that part is squared away.
  • Then address each part of the analysis one at a time. Set up the variable you need to keep the count, increment it at the right time, and print it out at the end. Compile and test at each step.
  • Finally, write the separate method to test a word for capitalization. Call it where appropriate. Test.
  • Once you've got the program working for the sample input file, make another one and test using it.

In: Computer Science

C++ I took 7/20 =( code: #include <iostream> #include<string.h> using namespace std; // function to calculate...

C++ I took 7/20 =(

code:

#include <iostream>
#include<string.h>

using namespace std;

// function to calculate number non white space characters
int GetNumOfNonWSCharacters(string str) {
int i = 0;
int count = 0;
while(str[i] != '\0') {
if(str[i] != ' ') {
count += 1;
}
i++;
}
return count;
}

// function to calculate numbers of words
int GetNumOfWords(string str) {
int i = 0;
int count = 1;
while(str[i] != '\0') {
if(str[i] == ' ' && str[i-1] != ' ') {
count += 1;
}
i++;
}
return count;
}


// function to find the number of occurence of the word
int FindText(string word, string str) {
int i = 0;
int count = 0;
while(str[i] != '\0') {
if(str[i] == word[0]) {
int k = i;
int j = 0;
while(word[j] != '\0') {
if(word[j] != str[k]) {
break;
}
if(word[j+1] == '\0') {
count += 1;
}
k++;
j++;
}
}
i++;
}
return count;
}


// function to replace the '!' in string
void ReplaceExclamation(string str) {
int i = 0;
string edited;
while(str[i] != '\0') {
if(str[i] == '!') {
edited[i] = '.';
}
else {
edited[i] = str[i];
}
i++;
}
edited[i] = '\0';

// display resulting string
int j = 0;
cout << "Edited Text:\n" << endl;
while(edited[j] != '\0') {
cout << edited[j];
j++;
}
cout << endl;
}


// function to remove extra spaces
void ShortenSpace(string str) {
int i = 0;
int j = 0;
int len = str.length();
string edited;
while(str[i] != '\0') {
if(str[i] != ' ') {
edited[j] = str[i];
j++;
}
else {
if(edited[j-1] != ' ') {
edited[j] = ' ';
j++;
}

}
i++;
}
edited[j] = '\0';

// display resulting string
int k = 0;
cout << "Edited Text:\n" << endl;
while(edited[k] != '\0') {
cout << edited[k];
k++;
}
cout << endl;
}


// function to display menu options
void PrintMenu(string str) {
while(1) {

// display menu
cout << "MENU" << endl;
cout << "c - Number of non-whitespace characters" << endl;
cout << "w - Number of words" << endl;
cout << "f - Find text" << endl;
cout << "r - Replace all !'s" << endl;
cout << "s - Shorten spaces" << endl;
cout << "q - Quit" << endl;

// read user option
char option;
cout << "Choose an option: ";
cin >> option;
  
// validate input
while(1) {
if(option != 'c' && option != 'w' && option != 'r' && option != 's' && option != 'q' && option != 'f') {
cout << "Choose an option: ";
cin >> option;
}
else{
break;
}
}

// perform the required operation
if(option == 'q') {
break;
}

else if(option == 'c') {
int non_whitespace_chars = GetNumOfNonWSCharacters(str);
cout << "Number of non-whitespace characters: " << non_whitespace_chars << endl;
}

else if(option == 'w') {
int num_words = GetNumOfWords(str);
cout << "Number of words: " << num_words << endl;
}

else if(option == 'f') {
string word;
cin.ignore();
getline(cin, word);
int finds = FindText(word, str);
cout << "Number of words or phrases found: " << finds << endl;
}

else if(option == 'r') {
ReplaceExclamation(str);
}

else {
ShortenSpace(str);
}

cout << endl;
}
}


// main function
int main() {

// read input text and output it
string text;
cout << "Enter sample text:" << endl;
getline(cin, text);
cout << "You entered:\n" << text << endl;

// call print menu function
PrintMenu(text);

return 0;
}

(1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 pt)

Ex:

Enter a sample text:
We'll continue our quest in space.  There will be more shuttle flights and more shuttle crews and,  yes,  more volunteers, more civilians,  more teachers in space.  Nothing ends here;  our hopes and our journeys continue!

You entered: We'll continue our quest in space.  There will be more shuttle flights and more shuttle crews and,  yes,  more volunteers, more civilians,  more teachers in space.  Nothing ends here;  our hopes and our journeys continue!


(2) Implement a PrintMenu() function, which has a string as a parameter, outputs a menu of user options for analyzing/editing the string, and returns the user's entered menu option. Each option is represented by a single character.

If an invalid character is entered, continue to prompt for a valid choice. Hint: Implement Quit before implementing other options. Call PrintMenu() in the main() function. Continue to call PrintMenu() until the user enters q to Quit. (3 pts)

Ex:

MENU
c - Number of non-whitespace characters
w - Number of words
f - Find text
r - Replace all !'s
s - Shorten spaces
q - Quit

Choose an option:


(3) Implement the GetNumOfNonWSCharacters() function. GetNumOfNonWSCharacters() has a constant string as a parameter and returns the number of characters in the string, excluding all whitespace. Call GetNumOfNonWSCharacters() in the PrintMenu() function. (4 pts)

Ex:

Number of non-whitespace characters: 181


(4) Implement the GetNumOfWords() function. GetNumOfWords() has a constant string as a parameter and returns the number of words in the string. Hint: Words end when a space is reached except for the last word in a sentence. Call GetNumOfWords() in the PrintMenu() function. (3 pts)

Ex:

Number of words: 35


(5) Implement the FindText() function, which has two strings as parameters. The first parameter is the text to be found in the user provided sample text, and the second parameter is the user provided sample text. The function returns the number of instances a word or phrase is found in the string. In the PrintMenu() function, prompt the user for a word or phrase to be found and then call FindText() in the PrintMenu() function. Before the prompt, call cin.ignore() to allow the user to input a new string. (3 pts)

Ex:

Enter a word or phrase to be found:
more
"more" instances: 5


(6) Implement the ReplaceExclamation() function. ReplaceExclamation() has a string parameter and updates the string by replacing each '!' character in the string with a '.' character. ReplaceExclamation() DOES NOT output the string. Call ReplaceExclamation() in the PrintMenu() function, and then output the edited string. (3 pts)

Ex.

Edited text: We'll continue our quest in space.  There will be more shuttle flights and more shuttle crews and,  yes,  more volunteers, more civilians,  more teachers in space.  Nothing ends here;  our hopes and our journeys continue.


(7) Implement the ShortenSpace() function. ShortenSpace() has a string parameter and updates the string by replacing all sequences of 2 or more spaces with a single space. ShortenSpace() DOES NOT output the string. Call ShortenSpace() in the PrintMenu() function, and then output the edited string. (3 pt)

Ex:

Edited text: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue!

In: Computer Science

Consider the appreciation of a currency. What effects might this have on international companies exporting overseas?...

Consider the appreciation of a currency. What effects might this have on international companies exporting overseas? What actions could companies take to minimize these effects?

please do it on word instead of notebook or image and mention references. it should be of approximately 500 words

thank you

In: Economics

For your company Nike: Evaluation of Financial Statements (note key word is “evaluation”) Overview Short-term liquidity...

For your company Nike:

  1. Evaluation of Financial Statements (note key word is “evaluation”)
    1. Overview
    2. Short-term liquidity
    3. Activity Ratios
    4. Financial Leverage (Debt Ratios)
    5. Profitability and Market Ratios
    6. Common-sized Income Statement Analysis
    7. Discussion of the Company’s capital structure

In: Accounting

In your own word please explain and write in complete sentences. How do you care for...

In your own word please explain and write in complete sentences.

How do you care for bleeding injury?

What is shock? How do you care for it?

What is asthma? How do you care for it?

What is anaphylaxis? How do you care for it?

In: Nursing