Questions
Please use Python! def getText(file): This function should open the file named file, and return the...

Please use Python!

def getText(file):

This function should open the file named file, and return the contents of the file formatted as a single string. During processing, you should (i) remove any blank lines, (ii) remove any lines consisting entirely of CAPITALIZED WORDS , and (iii) replace any explicit ’\n’ (newline) characters with spaces unless directly preceeded by a ’-’ (hyphen), in which case you should simply remove both the hyphen and the newline, restoring the original word.

def getText(file):

pass

def flushMarks(text):

This function should take as input a string such as what might be returned by getText() and return a new string with the following modifications to the input:

Remove possessives, i.e., "’s" at the end of a word;

Remove ’)’, ’(’, ’,’, ’:’, ’-’, ’_’, ’...’, ’"’ and "’"; and Replace ’!’, ’?’ and ’;’ with ’.’

A condition of this function is that it should be easy to change or extend the substitutions made. In other words, a function that steps through each of these substitutions in an open-coded fashion will not get full credit; write your function so that the substitutions can be modified or extended without having to significantly alter the code. Here’s a hint: if your code for this function is more than a few lines long, you’re probably not doing it right.

# Specification: takes a string, text, and removes possessives ('s)

# and most punctuation ('(),:\'"- —_').

#

def flushMarks(text):

pass

In: Computer Science

Hi, (C programming) I am looking to write a program that will encrypt a text file...

Hi,

(C programming)

I am looking to write a program that will encrypt a text file automatically once program has opened, and have the option to decrypt it in a menu in my program.

I have multiple text files that I need to encrypt, and would like if the program could encrypt all of them at once.

I would also only like to decrypt the a text file once the name has been entered into a scanf function.

In: Computer Science

C++ using vectors. in the following code, if a user adds duplicate names the votes should...

C++ using vectors.

in the following code, if a user adds duplicate names the votes should be added to only one of the names:

example

display "Enter candidate name: "

input john

display "Enter candidate vote:"

input 10

display "Enter candidate name: "

input john

display "Enter candidate vote:"

input 10

so the output has to be

john with 20 votes.

#include<iostream>

#include<iterator>

#include<string>

#include<algorithm>

#include<array>

#include<ctime>

#include <vector>

#include<bits/stdc++.h>

using namespace std;

int max_element(const vector<int>&stuff)

{

int max_index =0;

for (int i=1; i<stuff.size();++i)

if (stuff[i]>stuff[max_index])

max_index=i;

return max_index;

}

template <typename type>

void show(const vector<type>&stuff)

{

for (int i=0; i<stuff.size(); i++)

cout <<stuff[i]<<' ';

}

int main()

{

vector<string> names;

vector<int> votes;


string name;

int vote;

int size=5;

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

{

cout<<"enter candidates "<< i+1<<" name: ";

getline(cin, name,'\n');

cout<<"Enter "<<name<< "'s votes ";

cin>>vote;

cin.get();

names.push_back(name);

votes.push_back(vote);

}

  

for (int k=0; k<size;++k)

{

sort(names.begin(),names.end());

if (names[k-1]==names[k]){

return votes[k];

cout<<"votes "<<votes[k]<<endl;

}

}

int max_index= max_element(votes);

for (int j=0;j<size;++j){

if (votes[j]==votes[max_index])

cout<<"The winners list is bellow "<< names[j]<<endl;

}

return 0;

}

In: Computer Science

It is Microsoft Patch Tuesday and you are going to have patches automatically applied via Windows...

It is Microsoft Patch Tuesday and you are going to have patches automatically applied via Windows Server Update Services to the production servers. You have successfully tested them in a test environment and you are ready to have them applied to the production Microsoft Server Farm. Write an e-mail using the following requirements: 1) Informing users and application owners about the updates to these windows servers and when they will be applied. 2) Recommendation on what they should do before the patches have been applied 3) Recommendation on what they should do after the patching has been completed (to ensure that their applications are not impacted by the patching). 3) Assure them that the patches have been adequately tested in the Quality Assurance (QA) environment. 4) Tell them what they should do if errors are encountered, who they should inform and how it should be reported.

In: Computer Science

What will you review and assess within the Workstation Domain as part of this security assessment?

What will you review and assess within the Workstation Domain as part of this security assessment?

In: Computer Science

What will you review and assess in the User Domain as part of this security assessment?

What will you review and assess in the User Domain as part of this security assessment?

In: Computer Science

Write a JAVA code using regex methods and concepts The test string S should match the...

Write a JAVA code using regex methods and concepts The test string S should match the following requirements:

  • S must be of length 6
  • First character should not be a digit (1, 2, 3, 4, 5, 6, 7, 8, 9 or 0).
  • Second character should not be a lowercase vowel (a, e, i, o or u).
  • Third character should not be b, c, D or E.
  • Fourth character should not be a whitespace character (\r, \n, \t, \f or the space character).
  • Fifth character should not be an uppercase vowel (A, E, I, O or U).
  • Sixth character should not be a . or , symbol.

In: Computer Science

Discuss why an organization would want to develop an enterprise-wide approach to remote access via VPNs.

Discuss why an organization would want to develop an enterprise-wide approach to remote access via VPNs.

In: Computer Science

PRACTICAL 10 C PROGRAMMING. Question 1 - Reading into a dynamic array. Write a program called...

PRACTICAL 10 C PROGRAMMING.

Question 1 - Reading into a dynamic array.

Write a program called temperatures01 that reads a (non-empty) sequence maximum daily temperatures. Your program should first ask for the number of temperatures to read and dynamically allocate an array just big enough to hold the number of temperatures you read. You should then read in the elements of the array using a loop. You then should print out the elements of the array in reverse order (from most recent to oldest).

Test Cases

count     temperatures                          output
3         15.0 17.0 19.5                        19.5 17.0 15.0
5         16.5 18.8 20.5 21.3 16.2              16.2 21.3 20.5 18.8 16.5

Question 2- Dynamic odds-and-evens

Problem Definition

Write a program called odds_evens01 that reads a (non-empty) sequence of integers. As for question 1 above, your program should first ask for the number of integers to read and dynamically allocate an array just big enough to hold the number of values you read.

You should then read in the elements of the array using a loop. Then your program must dynamically allocate two arrays one to hold all the even numbers from the array you have just read and one to hold the odd numbers from the array. Your code must allocate just enough space to each of the arrays to hold the odd and the even numbers. For example, given the input:

3 4 5 6 9 1 2 8 2

ou must allocate an array of 4 values for the odd numbers and an array of 5 values for the even numbers. Your program must then print the values in the odd array and the even array.

Test Cases

Two test cases for the program are:

input              output
3 4 5 6 9 1 2 9    3 5 9 1 9    4 6 2
1 1 1 2 2 3 8      1 1 1 3      2 2 8

Write two more test cases in a text file called: odds_evens01.txt and save it in the directory for this practical.

Coding

Implement the problem definition above in a file called odds_evens01.c. Compile your program with -Wall to help improve the quality of your code. Note, you will need to write a dedicated loop just to count the number of odd and even elements there are so you can allocate the arrays for these. Also note, you may find some code from your previous sessions helpful in writing this solution. Make sure you save your code into your week10practice folder.

Question 3 - A dynamically growing array

Problem Definition

This is based on your answer to question 1.

One problem with the solution to questions 1 and 2 of of this practical is that the user has to know, in advance, how many values they will enter so we can allocate an array of the right size. In some cases it is better for a program just to keep reading values until the user types in a finishing value such as: -100.0.

In this problem you are to save your code from question 1 to write a new program called temperatures02. Then modify the code to:

  • initally allocate an array to hold up to 5 temperatures.
  • prompt the user to enter temperatures and type the value -100.0 when they are finished.
  • if the user fills up the array your program should
    • dynamically allocate a new array which is double the size.
    • copy the old values across to the new array.
    • deallocate the old array.
    • continue reading into the new array.

After you finish reading your array your program should, as before, output the temperatures read in reverse (most recent to oldest).

Test Cases

As before two test cases for your program would be:

count     temperatures                          output
3         15.0 17.0 19.5                        19.5 17.0 15.0
5         16.5 18.8 20.5 21.3 16.2              16.2 21.3 20.5 18.8 16.5

Coding

Implement the problem definition above in a file called temperatures02.c. Compile your program with -Wall to help improve the quality of your code. Make sure you save your code into your week10practice folder. Note: your loop to read values should be a while loop that terminates when you read the stopping value of -100.0.  Inside your loop you will need to have a check to see if you have reached the end of the currently allocated array and have code to perform the new allocation, copying and deallocation. You might want to write a small program to implement and test the logic for allocation, copying and deallocation so that you are confident that you have the process working before integrating it into your solution.

In: Computer Science

Discuss the best practices for IS Security Controls and Framework. Why are these controls important for...

Discuss the best practices for IS Security Controls and Framework. Why are these controls important for organizational data and assets?

In: Computer Science

Discuss the impact of attending a bidder’s conference. What types of insights are gained from attending...

Discuss the impact of attending a bidder’s conference. What types of insights are gained from attending these meetings?

In: Computer Science

(C++) D.Va's Mech System D.Va is a former professional gamer who now uses her skills to...

(C++) D.Va's Mech System

D.Va is a former professional gamer who now uses her skills to pilot a state-of-the-art mech in defense of her homeland. Her real name is Hana and you can read more about her story here (Links to an external site.).

We are writing a program for D.Va's mech to load up before combat. D.Va's mech has two main systems, the micro missile system and the damage matrix system. The micro missile system is used to give damage to the enemies while the damage matrix system is used to absorb damage from enemies. You've seen how D.Va combats on the field during class and we are writing a short program to help D.Va prepare her mech systematically. The link of the video "Shooting Star" is here (Links to an external site.) in case you missed class.

D.Va will be fighting many enemy bots and one enemy boss for each combat. Each enemy bots may have different power values. D.Va would need a damage matrix system strong enough to take all damages from enemies and enough micro missiles to destroy all enemies. D.Va's mech has default power for both the damage matrix system and the micro missile system. If the default power isn't enough, our system would need to load more power to either or both of the systems for D.Va to win the combat.

System Detail

Our system will first have some variables with initial values indicating enemy information and some default value for D.Va’s mech. It will then run three steps to analyze and prepare the mech for combat. First step is to calculate how much power D.Va needs given the number of enemies she's facing in combat. The second step is to load D.Va's mech with required power to fight the combat. Finally, the system will write the combat report into a file that D.Va can review before she goes into combat.

1. Initialization

Your system should start with variables initialization as following:

//Enemy Information
const int enemy_bots = 5;
int enemy_bot_power[enemy_bots] = {2, 5, 3, 7, 1};
float enemy_boss_power = 27.24;

//D.Va Default Spec
int micro_missiles = 10;
float defense_matrix_power = 100.0;

This would give you some enemy information including the number of enemy bots, their corresponding power(int), and enemy boss's power(float). This will also give you the default power of D.Va's mech including the number of micro missiles are loaded and how much power can the defense matrix absorb by default.

2. Calculate Power Needed

Then your system needs to calculate power needed for both the defense matrix system and the micro missile system. Please write two functions here, one to calculate the power needed by the defense matrix system and another to calculate the power needed by the micro missile system.

  1. Matrix Power: D.Va's matrix power would need to take all damage from bots and the boss. The damage of a bot is twice as strong as its power and the damage of a boss is four times stronger than its power. For example, if you have two bots with power 3 and 8 and a boss with power 13.2, the total damage would be  3*2 + 8*2 + 13.2*4 = 74.8. We will make a function named total_damage which takes in an array of ints indicating bots' power, an int indicating number of enemy bots we have, and a float indicating the boss's power. It would return a float telling us the total damage all enemies would give D.Va. That would then be how much power D.Va needs for her defense matrix system.
  2. Missile Power: D.Va's micro missile system would need to be five times stronger than the enemies' power. We will make a function named missile_power which takes in an int or a float as the parameter indicating the power of the enemy and return 5 times the parameter value as the power needed for the missile system. Note that this function would only take one number at a time, and the reason that the value could be an int or a float is that the power for the enemy bot is an int and for the enemy boss is a float. The return value would match the type of the parameter. For example, missile_power(5) would return 25, while missile_power(2.5) would return 12.5. Therefore you would want to use templates for this function. The total missile power needed for D.Va will then be the sum of all the returned values from the missile_power function. Make sure you calculate missile power for both the bots and the boss and add them all together in main.

3. Load D.Va

Now that we know how much power is needed for both D.Va's systems, let's load the power to D.Va's mech. You would want to write two functions here with the same name load_dva. Both load_dva() functions should have type void and take in two parameters. Their behaviors are slightly different. This is where we would use function overloading.

  1. Load Defense Matrix: To load the damage matrix, you want to change the value of the defense_matrix_power. If the power needed is less than the default defense_matrix_power value then we don't change it, if it's larger, we update the defense_matrix_power value with the power needed. Therefore this function would take in two parameters, the defense_matrix_power and the matrix power needed we calculated from step 2. Given that the function would update the value of one of its parameters, defense_matrix_power, please make sure you use pass by reference to update the value that's passed in.
  2. Load Micro Missiles: To load the micro missile system, you want to update the number of micro_missiles value, which indicates how many micro missiles we need in the mech. If the number of missiles needed is less than the default missiles then we don't need to change it, but if it's larger, we update the micro_missiles value. The number of micro missiles we need is equal to missile power needed(from step 2) divided by 100. Make sure you round this up to an integer, you can use ceil() from <cmath> to round up the float. For example, ceil(23.6) would return integer 24. Make sure you include <cmath> to use the function ceil. Similar to the other load_dva function, this load_dva function will also take two parameters, micro_missiles and the missile power needed that we calculated from step 2. Again, this function would modify the value of micro_missiles so make sure you pass in by reference instead of pass in by value.

Now in your main function you would have these two lines to load D.Va's mech:

//Load D.Va
load_dva(defense_matrix_power, matrix_power_needed);
load_dva(micro_missiles, missile_power_needed);

These two lines would update the value of defense_matrix_power and the micro_missiles.

4. Report

Finally, let's write a summary report for D.Va to read before she heads into the combat. Write a file name "report.txt" into the current directory. The content of the report should look likes this:

D.Va's Combat Report
Combat with 5 enemy bots and one enemy boss with power 27.24.
Loaded mech with 10 micro missiles and the defense matrix with power 144.96.
Ready for combat!

Note that the number of enemy bots, the boss power, the number of missiles, and the defense matrix power in the file are all results calculated from your program and inserted into the file. Please don't hard code the output file. I may change the value from step1 to test your code to see whether the report makes sense. Take the results from your previous calculation to write into the report file.

Please make sure you have logic to check file open in your code and close the file after you finish the file operations.

In: Computer Science

Project Management Standards and Project Management Methodologies Select two project management methodologies. Describe the type of...

Project Management Standards and Project Management Methodologies

  1. Select two project management methodologies. Describe the type of methodology (for example, sequential or iterative), benefits, features, type of organization, and best types of projects to implement using each of the methodologies.
  2. Choose the project management methodologies you like the best and describe why you like that methodology better than the other. Provide supporting evidence for your stance.

In: Computer Science

Discuss the processes involved with security assessments. What types of analysis is performed with this assessment?

Discuss the processes involved with security assessments. What types of analysis is performed with this assessment?

In: Computer Science

Translate the following C program into MIPS assembly language, allocate registers as you need, but document...

  1. Translate the following C program into MIPS assembly language, allocate registers as you need, but document the allocation.

int A[10]; // assume initialized elsewhere

int sum = 0;

int I = 0;

while (i<0) { sum += A[i++]; sum+= 2 ;}

plz do not copy from other answer, thx.

In: Computer Science