Questions
QUESTION 15 We need to write a function that calculates the power of x to n...

QUESTION 15

  1. We need to write a function that calculates the power of x to n e.g. power(5,3)=125.

    Which of the following is a right way to define power function?

    ______________________________________________________________

    int power(int a, int b)

    {

    int i=0, p=1;

    for(i=b;i>=1;i--)

      p*=a;

    return p;

    }

    ______________________________________________________________

    int power(int a, int b)

    {   

      int i=0, p=0;   

      for(i=1;i<=b;i--)       

        p=p*a;   

      return p;

    }

    ______________________________________________________________

    int power(int a, int b)

    {   

      int i=0, p=1;   

      for(i=b;i>=1;i--)       

        a*=p;   

      return p;

    }

    ______________________________________________________________

    int power(int a, int b)

    {   

      int i=0, p=1;   

      for(i=a;i>=1;i--)       

        p=p*b;   

      return p;

    }

    ______________________________________________________________

In: Computer Science

Your neighbor tells you that her nine-year-old son has been having behavior and academic problems in...

Your neighbor tells you that her nine-year-old son has been having behavior and academic problems in school. “His teacher recommended taking him to the pediatrician to get a prescription for Ritalin,” she said.

Make an argument for why your neighbor should first have her son evaluated by a clinical psychologist. Discuss the types of assessment tools the psychologist might use in his or her evaluation and how these tools would help in guiding diagnosis and treatment.

In: Psychology

I can’t get my code to work and/or finish it. Please fix. Below are code instructions...

I can’t get my code to work and/or finish it. Please fix. Below are code instructions and then sample runs and lastly my code so far.
//*********************************************************************
Program
You will write a program that uses a recursive function to determine whether a string is a character unit palindrome. Moreover, flags can be used to indicate whether to do case sensitive comparisons and whether to ignore spaces. For example "A nut for a jar of tuna" is a palindrome if spaces are ignored and not otherwise. "Step on no pets" is a palindrome whether spaces are ignored or not, but is not a palindrome if it is case sensitive since the ‘S’ and ‘s’ are not the same.

Background
Palindromes are character sequences that read the same forward or backwards (e.g. the strings "mom" or "123 454 321"). Punctuation and spaces are frequently ignored so that phrases like "Dog, as a devil deified, lived as a god." are palindromes. Conversely, even if spaces are not ignored phrases like "Rats live on no evil star" are still palindromes. .

Specifications
Command Line Parameters
The program name will be followed by a list of strings. The program will determine whether each string is a palindrome and output the results. Punctuation will always be ignored. An optional flag can precede the terms that modifies how a palindrome is determined.

Strings
Each string will be separated by a space on the command line. If you want to include a string that has spaces in it (e.g. "Rats live on no evil star"), then put quotes around it. The quote characters will not be part of the string that is read in.

Flags
Optional for the user
If present, flags always appear immediately after the program name and before any strings are processed and apply to all subsequent strings processed.
Flags must start with a minus (-) sign followed by flag values that can be capital or lowercase. e.g. -c, -S, -Cs, -Sc, -alphabetsoup, etc.
There are no spaces between starting minus (-) sign and flag(s).
Flags values are case insensitive.
c or C: Indicates that comparisons should be case-sensitive for all input strings. The default condition (i.e. if the flag is NOT included) is to ignore case-sensitivity. So, for example:
palindrome Mom should evaluate as being a palindrome.
palindrome -c Mom should not evaluate as being a palindrome.
s or S: Indicates that comparisons should not ignore spaces for all input strings. The default condition (i.e. if the flag is NOT included) is to ignore spaces. So, for example:
palindrome "A nut for a jar of tuna" should evaluate as being a palindrome.
palindrome -s "A nut for a jar of tuna" should not evaluate as being a palindrome.
Any flag values beside c and s are invalid (see program flow notes below)
Options can appear in different flags, e.g. you can use -Sc or -S -c
Repeated flags should be ignored, e.g. -ccs
The argument -- (two dashes) signifies that every argument that follows is not a flag (allowing for strings that begin with a dash), e.g. palindrome -- -s

Code Expectations
Your program should only get user input from the command line. (i.e. "cin" should not be anywhere in your code).
Required Functions:
Function that prints program usage message in case no input strings were found at command line.
Name: printUsageInfo
Parameter(s): a string representing the name of the executable from the command line. (Not a c string)
Return: void.
Function that determines whether a string is a character-unit palindrome.
Name: isPalindrome
Parameter(s): an input string, a boolean flag that considers case-sensitivity when true, and a boolean flag that ignores spaces when true. (Not a c string)
Return: bool.
Calls helper function isPalindromeR to determine whether string is a palindrome.
String passed into isPalindromeR after dealing with flags.
If case insensitive, make all lower or upper case so that case does not matter.
If spaces are ignored, remove spaces from string.
Helper recursive function that determines whether a string is a character-unit palindrome. This does not deal with flags.
Name: isPalindromeR
Parameter(s): an input string (Not a c string)
Return: bool
All functions should be placed in a separate file following the code organization conventions we covered.

Program Flow
Your program will take arguments from the command-line.
Determine if you have enough arguments. If not, output a usage message and exit program.
If flags are present.
Process and set values to use when processing a palindrome.
Loop through remaining arguments which are all input strings:
Process each by calling isPalindrome function with flag values.
Output results

Program Flow Notes:
Any time you encounter a syntax error, you should print a usage message and exit the program immediately.
E.g. an invalid flag

Hints
Remember rules for a good recursive function.
Recommended Functions to write:
Note: You could combine these into a single function. e.g. "preprocessString"
tolower - convert each letter to lowercase version for case insensitive comparisons.
Parameter(s): a string to be converted to lowercase
Return: a string with all lowercase characters
removePunctuation - Remove all punctuation marks possibly including spaces depending on the flag value.
Parameter(s): a string and a boolean flag indicating whether to also remove spaces
Return: a string with punctuation/spaces removed
Existing functions that might help:
tolower
substr
isalnum
erase (This can be used instead of substr, but is a bit more complicated.)
Example Output
Assumes executable is named palindrome
$ g++ … -o palindrome …

./palindrome
Usage: ./palindrome [-c] [-s] string ...
-c: turn on case sensitivity
-s: turn off ignoring spaces

./palindrome -c
Usage: ./palindrome [-c] [-s] string ...
-c: turn on case sensitivity
-s: turn off ignoring spaces

./palindrome Kayak
"Kayak" is a palindrome.

./palindrome -c Kayak
"Kayak" is not a palindrome.

./palindrome -C Kayak
"Kayak" is not a palindrome.

./palindrome -c kayak
"kayak" is a palindrome.

./palindrome "Test Set"
"Test Set" is a palindrome.

./palindrome -sc "Test Set"
"Test Set" is not a palindrome.

./palindrome -s -c "Test Set"
"Test Set" is not a palindrome.

./palindrome -s -s "Test Set"
"Test Set" is not a palindrome.

./palindrome -scs "Test Set"
"Test Set" is not a palindrome.

./palindrome Kayak madam "Test Set" "Evil Olive" "test set" "loop pool"
"Kayak" is a palindrome.
"madam" is a palindrome.
"Test Set" is a palindrome.
"Evil Olive" is a palindrome.
"test set" is a palindrome.
"loop pool" is a palindrome.

#include <iostream>
#include <cctype>
#include <string>

using namespace std;

void printUsageInfo(string executableName) {
cout << "Usage: " << executableName << " [-c] [-s] string ... " << endl;
cout << " -c: turn on case sensitivity" << endl;
cout << " -s: turn off ignoring spaces" << endl;
exit(1);

//prints program usage message in case no strings were found at command line
}

bool isPalindrome(string str, bool caps, bool space) {

//determines whether a string is a character-unit palindrome
//should do everytyhing to find palindrome
return false;
}

bool isPalindromeR(string str, start, end) {
if (start >= end)
return true;

if(str.at(start) != str.at(end))
return false;
return isPalindromeR(str, ++start, --end);

//helper recursive function that determines whether string is a character-unit palindrome
}


string tolower(string str) {
for (unsigned int i = 0; i < str.length(); i++){
str.at(i) = tolower(str.at(i));
}
return str; //change to return string in all lowercase chars
}

string removePunctuation (string str, bool space) {
for(unsigned int i = 0; i < str.length(); i++){
if (ispunct(str.at(i))) {
str.erase(i);
cout << str;
}
}

return str;
//change to return string w/ punctuation/spaces removed
}
//****
int main(int argc, char* argv[]) {

bool caps = false;
bool space = true;
string executableName = argv[0];

if (argc < 2)
printUsageInfo(argv[0]);

int startIndex = 1;
int i = 1;

if ('-' == argv[1][0]) {
startIndex++;
while((argv[1][i]) != '\0') {
if ('c' == tolower(argv[1][i])){
caps = true;
}
else if ('s' == tolower(argv[1][i])) {
space = true;
}
else { //not a flag
printUsageInfo(argv[0]);
break;
}
i++;
}//while
//cout << space << endl;
//cout << caps << endl;
} //if

else {

}

//TO DO

for(int j = startIndex; j < argc; ++j) {
if (caps) {
cout << tolower(argv[j]);
}
else if (space) {
cout << removePunctuation(argv[j], space);
}
else if (caps && space){
cout << "seriously, fix me";
}
else {
cout << "else";
}
}
cout << endl;

//isPalindrome(cup, bool caps, bool space);
cout << "end of program" << endl;
return 0;
}


In: Computer Science

Three entrepreneurs plan to open a copy shop. It costs $5000 per year to rent a...

Three entrepreneurs plan to open a copy shop. It costs $5000 per year to rent a copier. It costs $0.03 per copy to operate the copier. Other fixed costs of running the store will amount to $400 per month. The planned price per copy is $0.10. The shop will be open 365 days per year. Each copier can make up to 100,000 copies per year.

SHOW THE FOLLOWING IN EXCEL( show the formulas and calculation)within excel !!!  THANK YOU SO SO MUCH!

  1. Use Goal Seek feature to determine annual break-even point for the use of three rented copiers by changing (1) copy units, (2) unit pricing, (3) per variable costs, and (4) fixed costs.

In: Operations Management

I understand how electrons initially move into another's vicinity, but nowhere can I find a fathomable...

I understand how electrons initially move into another's vicinity, but nowhere can I find a fathomable answer to this. Also, does the pairs forming 'a condensate' mean a Bose-Einstein condensate?

In: Physics

The work climate has proven to be an effective measuring stick to successful performance. Tell what...

The work climate has proven to be an effective measuring stick to successful performance. Tell what effective organizational leaders

can do to ensure the work climate is conducive to safety, crisis management, product improvement, professional development, and

overall productivity. Tell what process can be utilized to measure work climate.

In: Operations Management

1b. Explain each of the following with an example in two languages of your choice for...

1b. Explain each of the following with an example in two languages of your choice for each item. (25 points)

  • Orthogonality

  • Generality

  • Uniformity

In: Computer Science

Zinc sulfide, ZnS, exists in two main crystal forms. The more stable form, zinc blende, is...

Zinc sulfide, ZnS, exists in two main crystal forms. The more stable form, zinc blende, is face-centered cubic with tetrahedral coordination geometry and has density of 4.09 g/cm3. Use 184 pm for the ionic radius of S2- to calculate the ionic radius of Zn2+.

In: Chemistry

Assignment # 6: Chain of Custody Roles and Requirements Learning Objectives and Outcomes Describe the requirements...

Assignment # 6: Chain of Custody Roles and Requirements

Learning Objectives and Outcomes

  • Describe the requirements of a chain of custody.
  • Differentiate the roles of people involved in evidence seizure and handling.

Assignment Requirements

You are a digital forensics intern at Azorian Computer Forensics, a privately owned forensics investigations and data recovery firm in the Denver, Colorado area. Azorian has been called to a client’s site to work on a security incident involving five laptop computers. You are assisting Pat, one of Azorian's lead investigators. Pat is working with the client's IT security staff team leader, Marta, and an IT staff member, Suhkrit, to seize and process the five computers. Marta is overseeing the process, whereas Suhkrit is directly involved in handling the computers.

The computers must be removed from the employees' work areas and moved to a secure location within the client's premises. From there, you will assist Pat in preparing the computers for transporting them to the Azorian facility.

BACKGROUND

Chain of Custody

Evidence is always in the custody of someone or in secure storage. The chain of custody form documents who has the evidence in their possession at any given time. Whenever evidence is transferred from one person to another or one place to another, the chain of custody must be updated.

A chain of custody document shows:

  • What was collected (description, serial numbers, and so on)
  • Who obtained the evidence
  • Where and when it was obtained
  • Who secured it
  • Who had control or possession of it

The chain of custody requires that every transfer of evidence be provable that nobody else could have accessed that evidence. It is best to keep the number of transfers as low as possible.

Chain of Custody Form

Fields in a chain of custody form may include the following:

  • Case
  • Reason of evidence obtained
  • Name
  • Title
  • Address from person received
  • Location obtained from
  • Date/time obtained
  • Item number
  • Quantity
  • Description

For each evidence item, include the following information:

  • Item number
  • Date
  • Released by (signature, name, title)
  • Received by (signature, name, title)
  • Purpose of chain of custody

For this assignment:

  1. Walk through the process of removal of computers from employees’ work areas to the client's secure location and eventually to the Azorian facility. Who might have possession of the computers during each step? Sketch a rough diagram or flow chart of the process.
  2. Each transfer of possession requires chain of custody documentation. Each transfer requires a signature from the person releasing the evidence and the person receiving the evidence. Include the from/to information in your diagram or flow chart.

In: Computer Science

What biological, psychological, and social cultural influences affect our experience of pain? How do placebos, distraction,...

What biological, psychological, and social cultural influences affect our experience of pain? How do placebos, distraction, and hypnosis help control pain? Provide example from your experience in your answer.

Note: the answer should be three paragraphs, cited, and use chapter 6 of Myers and DeWall psychology text book. (12e)

In: Psychology

A spherical object has an outside diameter of 60.0cm . Its outer shell is composed of...

A spherical object has an outside diameter of 60.0cm . Its outer shell is composed of aluminum and is 2.80cm thick. The remainder is uniform plastic with a density of 720kg/m3 .

A) Determine the object's average density.

B) Will this object float by itself in fresh water?

In: Physics

Write the code for binary min heap in c++ .

Write the code for binary min heap in c++ .

In: Computer Science

Starting with a 30% (w/w) solution of hydrogen peroxide, how many mL would you need to...

Starting with a 30% (w/w) solution of hydrogen peroxide, how many mL would you need to dilute in order to end up with 25.00mL of a 3.6 M hydrogen peroxide solution? What are the hazards and safety precautions associated with 30% hydrogen peroxide. Assume a solution density of 1.11 g/mL.

In: Chemistry

An object with a density of 761.0 kg/m3 and a mass of 1399.0 kg is thrown...

An object with a density of 761.0 kg/m3 and a mass of 1399.0 kg is thrown into the ocean. Find the volume that sticks out of the water. (use ?seawater = 1024 kg/m3)

In: Physics

British Columbia Lumber has a raw lumber division and a finished lumber division. The variable costs...

British Columbia Lumber has a raw lumber division and a finished lumber division. The variable costs are as follows:

Raw lumber division: R100 per 100 m² of raw lumber
Finished lumber division: R125 per 100 m² of finished lumber

Assume that there is no m² loss in processing raw lumber into finished lumber. Raw lumber can be sold at R200 per 100 m². Finished lumber can be sold at R275 per 100 m².

Required:

2.1 Should British Columbia Lumber process raw lumber into its finished form? Show your calculations.

2.2 Assume that internal transfers are made at 110% of variable costs. Will each division maximise its division contribution by adopting the action that is in the best interest of British Columbia Lumber as a whole? Explain.

2.3 Assume that the internal transfers are made at market prices. Will each division maximise its division contribution by adopting the action that is in the best interest of British Columbia Lumber as a whole? Explain.

In: Accounting