Questions
Map word scanning in C++ For some context, I've been working on a program in which...

Map word scanning in C++

For some context, I've been working on a program in which I must enter in words and clear them of any potential punctuations. If a word has punctuation in the middle of the word, I must ignore the letters AFTER the punctuation and delete the punctuation as well. For example if I enter in "fish_net" I will only get "fish" back. I must also keep track of the occurrence of each word as well as number of words.

Here's my problem, I'm using a do while loop to continuously enter in words and break from it when needed. When I do, my output is supposed to be separate words, but they are getting merged with each other and counting it as one word. For example, lets say I enter in the words: "hello" "there" "done". The INTENDED output should be the following: hello 1 (newline) there 1 (newline) done 1. However, the output CURRENTLY goes like this: hello 1 (newline) hellothere 1 (newline) hellotheredone 1. Mind you that the numbers after the words are the number of occurrences that word is entered.

#include <iostream>
#include<map>
#include<string>
#include <algorithm>
using namespace std;

void get_words(map<string, int>&);
void print_words(const map<string, int>&);
void clean_entry(const string&, string&);

int main()
{
   map<string,int>m;
   get_words(m);
   print_words(m);
}

void get_words(map<string, int>&m)
{
   string word, cleaned_words = "";
   cout << "Enter in a string of text: ";
   do
   {  
       cin >> word;
       clean_entry(word, cleaned_words);

       if (cleaned_words.length() != 0)
       {
           m[cleaned_words]++;//inserting clean words into map
       }
  
   } while (word != "done");
}

void print_words(const map<string, int>&m)
{  
   int non_empty_words = 0;
   for (auto it = m.begin(); it != m.end(); it++)
   {
       cout << it->first << " " << it->second << endl;
       non_empty_words += it->second;
   }
   cout << "Non-empty words: " << non_empty_words << endl;
   cout << "Words: " << m.size();
}

void clean_entry(const string&words, string&cleaned_words)
{
   int len = words.length();
   int i = 0;
   while (i < len && ispunct(words[i])) i++;//parse through initial punctuation (make sure that punctuation is deleted while leaving word intact if in front or back)
   while (i < len && !ispunct(words[i]))//while we come across any words with no punctuation, we add it to cleaned words
   {
       cleaned_words += words[i];
       i++;
   }
}

In: Computer Science

Read the following case study for Coca-Cola and prepare a SWOT analysis for it. Coca-Cola is...

Read the following case study for Coca-Cola and prepare a SWOT analysis for it.
Coca-Cola is a highly popular brand with a unique brand identity. Its soft drinks are the most-selling drinks in history, one of the most renowned brands with the highest brand equity. It was also awarded ‘highest brand equity award’ in 2011. It is sold in more than 200 countries with 9 billion servings per day of Company products. It has introduced more than 500 new products globally. Some of these are variations of Coca-Cola beverage, like Coco Cola Vanilla and Cherry Coca-Cola. Its brands are known to touch every lifestyle and demography.
Coca-Cola is considered one of US’s most emotionally-connected brands. This valuable brand is associated with ‘happiness’ and has strong customer loyalty. Customers can quickly identify their particular taste. Finding its substitutes is difficult for them. Moreover, Coca-Cola and Fanta have a huge fan following than other beverage names in the industry. Coca-Cola is listed as the 3rd Best Global Brand on Interbrand’s annual ranking. Having an estimated brand value of $79.96 billion, it has retained the top position for many years.
However, Carbonated drinks are one of the major sources of sugar intake. It results in two grave health issues – obesity and diabetes. Coca-Cola is the biggest manufacturer of carbonated beverages. Many health experts have prohibited the use of these soft drinks. It is a controversial issue for the company. However, Coca-Cola hasn’t devised any health alternative or solution for this problem yet.
Out of Coca-Cola and Pepsi, the only two largest manufacturers of soft drinks in the beverage segment, Coca-Cola has the largest market share. Coke, Sprite, Diet Coke, Fanta, Limca, and Maaza are the highest growth drivers for Coca-Cola. It also has the most efficient and most extensive distribution network in the world. The company has nearly 250 bottling partners globally.
Pepsi is the biggest rival of Coca-Cola. Had it not been Pepsi, Coca-Cola would have been the clear market leader in the beverage. Coca-Cola has low product diversification. Where Pepsi has launched many snacks items like Lays and Kurkure, Coca-Cola is lagging in this segment. It gives Pepsi leverage over Coca-Cola. Coca-Cola has the chance to introduce new offerings in health and food segments just like Pepsi. It can contribute to their revenue, and they can branch out from carbonated drinks. Coca-Cola owns several packaged drinking water brands like Kinley. There is a great potential for expansion in this segment for Coca-Cola. Yet, there is a way to expand and bring healthier drinks in the market to avoid people’s criticism.
Coca-Cola has faced many criticisms over its water management issue. Many social and environmental groups have claimed that the company has a vast consumption of water in water-scarce regions. Besides, people have alleged that Coca-Cola is polluting water and mixing pesticides in water to clear contaminants. In addition, Greenpeace censured Coca-Cola in its published report in 2017 for its use of single-use plastic bottles. It has also been criticized over its recycling and renewable sources.
Many regions with hot climate have the highest consumption for cold drinks. Thus, increasing presence in such locations can be excellent – Middle Eastern and African countries are a good example. Coca-Cola acquired AdeS in 2016. AdeS is the largest soy-based beverage brand in Latin America. Through this acquisition, Coca-Cola expanded its ready-to-drink beverage portfolio.
Coca Cola’s business is entirely dependent upon logistics and supply chain. Transportation costs and fuel prices are always on the rise. Thus, coming up with some advanced and improved systems for distribution can be a way out from this problem.

In: Operations Management

Read the following case study for Coca-Cola and prepare a SWOT analysis for it. Coca-Cola is...

Read the following case study for Coca-Cola and prepare a SWOT analysis for it.

Coca-Cola is a highly popular brand with a unique brand identity. Its soft drinks are the most-selling drinks in history, one of the 7+most renowned brands with the highest brand equity. It was also awarded ‘highest brand equity award’ in 2011. It is sold in more than 200 countries with 9 billion servings per day of Company products. It has introduced more than 500 new products globally. Some of these are variations of Coca-Cola beverage, like Coco Cola Vanilla and Cherry Coca-Cola. Its brands are known to touch every lifestyle and demography.

Coca-Cola is considered one of US’s most emotionally-connected brands. This valuable brand is associated with ‘happiness’ and has strong customer loyalty. Customers can quickly identify their particular taste. Finding its substitutes is difficult for them. Moreover, Coca-Cola and Fanta have a huge fan following than other beverage names in the industry. Coca-Cola is listed as the 3rd Best Global Brand on Interbrand’s annual ranking. Having an estimated brand value of $79.96 billion, it has retained the top position for many years.

However, carbonated drinks are one of the major sources of sugar intake. It results in two grave health issues – obesity and diabetes. Coca-Cola is the biggest manufacturer of carbonated beverages. Many health experts have prohibited the use of these soft drinks. It is a controversial issue for the company. However, Coca-Cola hasn’t devised any health alternative or solution for this problem yet.

Out of Coca-Cola and Pepsi, the only two largest manufacturers of soft drinks in the beverage segment, Coca-Cola has the largest market share. Coke, Sprite, Diet Coke, Fanta, Limca, and Maaza are the highest growth drivers for Coca-Cola. It also has the most efficient and most extensive distribution network in the world. The company has nearly 250 bottling partners globally.

Pepsi is the biggest rival of Coca-Cola. Had it not been Pepsi, Coca-Cola would have been the clear market leader in the beverage. Coca-Cola has low product diversification. Where Pepsi has launched many snacks items like Lays and Kurkure, Coca-Cola is lagging in this segment. It gives Pepsi leverage over Coca-Cola. Coca-Cola has the chance to introduce new offerings in health and food segments just like Pepsi. It can contribute to their revenue, and they can branch out from carbonated drinks. Coca-Cola owns several packaged drinking water brands like Kinley. There is a great potential for expansion in this segment for Coca-Cola. Yet, there is a way to expand and bring healthier drinks in the market to avoid people’s criticism.

Coca-Cola has faced many criticisms over its water management issue. Many social and environmental groups have claimed that the company has a vast consumption of water in water-scarce regions. Besides, people have alleged that Coca-Cola is polluting water and mixing pesticides in water to clear contaminants. In addition, Greenpeace censured Coca-Cola in its published report in 2017 for its use of single-use plastic bottles. It has also been criticized over its recycling and renewable sources.

Many regions with hot climate have the highest consumption for cold drinks. Thus, increasing presence in such locations can be excellent – Middle Eastern and African countries are a good example. Coca-Cola acquired AdeS in 2016. AdeS is the largest soy-based beverage brand in Latin America. Through this acquisition, Coca-Cola expanded its ready-to-drink beverage portfolio.

Coca Cola’s business is entirely dependent upon logistics and supply chain. Transportation costs and fuel prices are always on the rise. Thus, coming up with some advanced and improved systems for distribution can be a way out from this problem.

In: Operations Management

In December of 1903, Wilbur and Orville Wright made history with their bi-plane contraption that managed...

In December of 1903, Wilbur and Orville Wright made history with their bi-plane contraption that managed to do the seemingly impossible: it gave man the ability to fly. The concept was so unearthly, in fact, that private aviation first took off not as a means of transportation, but as a sideshow of sorts. In those pioneer days, seeing a man use technology to overcome gravity was such a novelty that early aviators made their living mostly through exhibition flights.

Seven years after the Wright Brothers proved flight was possible, a car salesman by the name of Clyde Cessna found himself awestruck by one such exhibition in Oklahoma. He’d heard tales of men taking to the skies in these machines (and making thousands of dollars in the process), and now that he’d seen one in person he was certain: Clyde Cessna was going to build an airplane of his own.

The Cessna Aviation Company was an American general aviation aircraft manufacturing corporation headquartered in Wichita, Kansas. Cessna produced small, piston-powered aircraft, as well as business jets. For many years the company was one of the highest-volume producers of general aviation aircraft in the world. The company was founded in 1927.

The following information is available concerning a firm's capital:

Debt: 500,000 bonds with a face value of $1000 and an initial 20-year term were issued five years ago with a coupon rate of 8%. Today these bonds are selling for $846.30.

Preferred stock: 200,000 shares of preferred stock paying an annual dividend of $9.50 are outstanding. The shares currently trade at $79.16.

Common equity: Two hundred thousand shares of common stock are outstanding which are now selling for $22.50 per share. An annual dividend of $1.70 was just paid and is expected to grow indefinitely at 6%.

The combined federal and state tax rate is 40%.

Required:

Calculate the firm's WACC.

In: Accounting

A three storey structure having a square footprint of 225 m2 is constructed on a clayey...

A three storey structure having a square footprint of 225 m2 is constructed on a clayey deposit. The structure is planned to be supported by square isolated footings having a width of 2m and spaced at 5m center to center. A typical borehole indicates that the soil consists of 2m fill layer at the top (g=17KN/m3) followed by a very stiff clay layer 2m thick (gsat=18.5KN/m3) underlain by a normally consolidated soft clay layer of 4.5m thickness (gsat=17KN/m3) followed by a rock layer extending down to the bottom of borehole. The foundations are laid on top of the stiff clay layer. Water table is located at the top of the stiff clay layer. Undisturbed samples were taken from the middle of each clay layer and consolidation tests done on undisturbed samples indicated the following:

 Stiff Clay: Cc=0.15; Cs = 0.02; Pc = 120 kPa; e0=0.9

 Soft Normally Consolidated Clay: Cc=0.38; Cs = 0.06; e0=1.0

a) Draw a sketch representing the various problem components.

b) The isolated foundations are subjected to a stress of 140 kPa. Calculate the consolidation settlement. Consider the very stiff clay as one layer and divide soft clay layer into two equal sub-layers. Calculate settlement under one typical foundation.

c) What would be the maximum additional stress applied on a central foundation from two neighboring foundations (situated at the left and right sides of the central foundation). Is it necessary to consider the additional stresses from neighboring foundations in the settlement calculations?

d) A concern is the differential settlement between isolated adjacent footings. It was decided to change the design to have the structure founded on a raft foundation subjected to a stress of 45 kPa. Compute the consolidation settlement and comment on the results.

In: Civil Engineering

Business Applications  Operating leverage: Description of business for Caterpillar, Inc. With 2014 sales and revenues of $55.184...

Business Applications  Operating leverage: Description of business for Caterpillar, Inc.

With 2014 sales and revenues of $55.184 billion, Caterpillar is the world’s leading manufacturer of construction and mining equipment, diesel and natural gas engines, industrial gas turbines and diesel-electric locomotives. The company principally operates through its three product segments—Resource Industries, Construction Industries, and Energy & Transportation (formerly Power Systems)—and also provides financing and related services through its Financial Products segment. Caterpillar is also a leading U.S. exporter.

Description of business for the Kroger Company from its Form 10-K:

The Kroger Co. was founded in 1883 and incorporated in 1902. As of January 31, 2015, we are one of the largest retailers in the nation based on annual sales. . . .

As of January 31, 2015, Kroger operated, either directly or through its subsidiaries, 2,625 supermarkets and multi-department stores, 1,330 of which had fuel centers. Approximately 48% of these supermarkets were operated in Company-owned facilities, including some Company-owned buildings on leased land. Our current strategy emphasizes self-development and ownership of store real estate. Our stores operate under several banners that have strong local ties and brand recognition. Supermarkets are generally operated under one of the following formats: combination food and drug stores (“combo stores”); multi-department stores; marketplace stores; or price impact warehouses.

Required

  1. Determine which company appears to have the higher operating leverage.
  2. Write a paragraph or two explaining why the company you identified in Requirement a might be expected to have the higher operating leverage.
  3. If revenues for both companies increased by 5 percent, which company do you think would likely experience the greater percentage increase in operating earnings? Explain your answer

In: Accounting

// This program ask the user to enter a character. It then performs a // linear...

// This program ask the user to enter a character. It then performs a

// linear search on a character array and display the number of times

// that the character appears on the array. If the character is not in the

// array, then it will display a message saying that is was not found.

// Add the necessary code for the program to work.

// NOTE:

// You don't have to edit anything in the main(), just in the searchArray() function.

// EXAMPLES:

// Input: Enter a letter to search for: h

// Output: The are 2 number of 'h' letters in the list

// Input: Enter a letter to search for: n

// Output: The are 2 number of 'n' letters in the list

// Input: Enter a letter to search for: z

// Output: The letter z was not found in the list

#include<iostream>

using namespace std;

int searchArray(char[], int, char); // function prototype

const int SIZE = 10;

int main()

{

              //char charArray[SIZE] = {'h', 'h', 'a', 'r', 'p', 'o', 'o', 'n', 'n', '\0'};

              char charArray[SIZE] = "hharpoonn";

              int found;

              char ch;

              cout << "Enter a letter to search for: ";

              cin >> ch;

              found = searchArray(charArray, SIZE, ch);

              if (found == 0)

                             cout << "The letter " << ch

             << " was not found in the array" << endl;

              else

                             cout << "The are " << found << " number of '" << ch

                                           <<"' letters in the array" << endl;

              return 0;

}

//*******************************************************************

//                      searchArray

//

// task:       This searches an array for a particular value

// data in:       Array of values, the number of

//                elements in the array, and the value searched for

//                in the array

// data returned: Number of times the value appears in the list or 0

//                                                      if the value is not found

//

//*******************************************************************

int searchArray(char array[], int numElems, char value)

{

              // Counter, contains the number of times the character appears on the array.

              int count = 0;

              // Add code to search the array and count the number of times the

              // character appears in it.

              // HINT: for-loop similar to the one in linearSearch.cpp

              // Complete the return statement. If the value is found, returns the

              // number of characters founded. If the value is not found, 0 is returned.

              return _________;

}

In: Computer Science

Write a Java program that sorts an array of “Student” in an aescending order of their...

Write a Java program that sorts an array of “Student” in an aescending order of their “last names”. The program should be able to apply (Insertion sort):

Student [] studs = new Student[8];

s[0] = new Student("Saoud", "Mohamed", 3.61);

s[1] = new Student("Abdelkader", "Farouk", 2.83);

s[2] = new Student("Beshr" , "Alsharqawy", 1.99);

s[3] = new Student("Nader", "Salah", 3.02);

s[4] = new Student("Basem", "Hawary", 2.65);

s[5] = new Student("Abdullah", "Babaker", 2.88);

s[6] = new Student("Abdelaal", "Khairy", 3.13);

s[7] = new Student("Mohamedain", "Marsily", 4.00);

In: Computer Science

public class SumMinMaxArgs { private int[] array; // You will need to write the following: //...

public class SumMinMaxArgs {
    private int[] array;
    // You will need to write the following:
    //
    // 1. A constructor that takes a reference to an array,
    //    and initializes an instance variable with this
    //    array reference
    //
    // 2. An instance method named sum, which will calculate
    //    the sum of the elements in the array.  If the array
    //    is empty (contains no elements), then this will
    //    will return 0.  You will need a loop for this.
    //
    // 3. An instance method named min, which will return
    //    whichever element in the array is smallest.
    //    You can assume that min will only be called if the
    //    array is non-empty (contains at least one element).
    //    You will need a loop for this.  You may use the
    //    Math.min method here (see link below for more)
    //    https://www.tutorialspoint.com/java/lang/math_min_int.htm
    //
    // 4. An instance method named max, which will return
    //    whichever element in the array is largest.
    //    You can assume that max will only be called if the
    //    array is non-empty (contains at least one element).
    //    You will need a loop for this.  You may use the
    //    Math.max method here (see link below for more)
    //    https://www.tutorialspoint.com/java/lang/math_min_int.htm
    //
    // TODO - write your code below


    // DO NOT MODIFY parseStrings!
    public static int[] parseStrings(String[] strings) {
        int[] retval = new int[strings.length];
        for (int x = 0; x < strings.length; x++) {
            retval[x] = Integer.parseInt(strings[x]);
        }
        return retval;
    }

    // DO NOT MODIFY main!
    public static void main(String[] args) {
        int[] argsAsInts = parseStrings(args);
        SumMinMaxArgs obj = new SumMinMaxArgs(argsAsInts);
        System.out.println("Sum: " + obj.sum());
        System.out.println("Min: " + obj.min());
        System.out.println("Max: " + obj.max());
    }
}
Sum: 15
Min: 1
Max: 5
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertArrayEquals;
import org.junit.Test;

public class SumMinMaxArgsTest {
    @Test
    public void testParseStringsLength0() {
        assertArrayEquals(SumMinMaxArgs.parseStrings(new String[0]),
                          new int[0]);
    }

    @Test
    public void testParseStringsLength1() {
        assertArrayEquals(SumMinMaxArgs.parseStrings(new String[]{"1"}),
                          new int[]{1});
    }

    @Test
    public void testParseStringsLength2() {
        assertArrayEquals(SumMinMaxArgs.parseStrings(new String[]{"1", "42"}),
                          new int[]{1, 42});
    }

    @Test
    public void testSumArrayLength0() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[0]);
        assertEquals(0, obj.sum());
    }

    @Test
    public void testSumArrayLength1() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{1});
        assertEquals(1, obj.sum());
    }

    @Test
    public void testSumArrayLength2() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{1, 2});
        assertEquals(3, obj.sum());
    }

    @Test
    public void testSumArrayLength3() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{1, 2, 3});
        assertEquals(6, obj.sum());
    }

    @Test
    public void testSumArrayLength4() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{1, 2, 3, 4});
        assertEquals(10, obj.sum());
    }
    
    @Test
    public void testMinArrayLength1() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{1});
        assertEquals(1, obj.min());
    }

    @Test
    public void testMinArrayLength2MinFirst() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{1, 2});
        assertEquals(1, obj.min());
    }

    @Test
    public void testMinArrayLength2MinSecond() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{2, 1});
        assertEquals(1, obj.min());
    }

    @Test
    public void testMinArrayLength3MinFirst() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{1, 2, 3});
        assertEquals(1, obj.min());
    }

    @Test
    public void testMinArrayLength3MinSecond() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{2, 1, 3});
        assertEquals(1, obj.min());
    }

    @Test
    public void testMinArrayLength3MinThird() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{3, 2, 1});
        assertEquals(1, obj.min());
    }

    @Test
    public void testMaxArrayLength1() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{1});
        assertEquals(1, obj.max());
    }

    @Test
    public void testMaxArrayLength2MaxFirst() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{2, 1});
        assertEquals(2, obj.max());
    }

    @Test
    public void testMaxArrayLength2MaxSecond() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{1, 2});
        assertEquals(2, obj.max());
    }

    @Test
    public void testMaxArrayLength3MaxFirst() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{3, 2, 1});
        assertEquals(3, obj.max());
    }

    @Test
    public void testMinArrayLength3MaxSecond() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{2, 3, 1});
        assertEquals(3, obj.max());
    }

    @Test
    public void testMaxArrayLength3MaxThird() {
        SumMinMaxArgs obj = new SumMinMaxArgs(new int[]{2, 1, 3});
        assertEquals(3, obj.max());
    }
} // SumMinMaxArgsTest

In: Computer Science

Kara and Brandon Arnold are married and file a joint return. Their Social Security numbers are 000-00-1111 and 000-00-2222

Kara and Brandon Arnold are married and file a joint return. Their Social Security numbers are 000-00-1111 and 000-00-2222, respectively. Kara and Brandon have one son, Henry, age 3. His Social Security number is 000-00-3333. They live at 356 Welcome Lane, Woodbury, WA 84653. They report their income on the cash method. During 2017, they report the following items:

Salary

$103,000

Interest income from money market accounts

600

Dividend income from Davis Corp. stock

700

Cash contributions to church

6,000

 

 

Rental of a condominium in Lutsen:

 

Rental income (30 days)

12,000

Interest expense

7,000

Property taxes

3,200

Maintenance

1,700

Depreciation (entire year)

7,500

Insurance

2,000

Days of personal use

16


The address of the Condo is 1127 Skyline Drive, Lutsen, WA 84666. During the year the following events also occur:
a. In 2015, Brandon had loaned a friend $3,000 to help pay medical bills. During 2017, he discovers that his "friend" has skipped town.

b. On June 20, 2017, Brandon sells Kim Corporation stock for $16,000. He purchased the stock on December 12, 2011 for $22,000.

c. On September 19, 2017, Kara discovers that the penny stock of Roberts, Inc. she purchased on January 2 of the prior year is completely worthless. She paid $5,000 for the stock.

d. Instead of accepting $60 the utility store offers for their old dishwasher, they donate it to Good,vill on November 21, 2017. They purchased the dishwasher for $750 on March 30, 2007. The new dishwasher cost $900.

e. Kara and Brandon purchased a ne,v residence for $250,000. As part of the closing costs, they pay two points, or $3,800, on the mortgage, which is interest rather than loan processing fees. This payment enables them to obtain a more favorable interest rate for the term of the loan. They also paid $8,400 in interest on their mortgage on their personal residence.

f. They pay $4,100 in property taxes on their residence and $7,500 in state income taxes.

g. On July 20, 2017, Kara and Brandon donate 1,000 shares of Anton, Inc. stock to the local community college. The value of the stock on that date is $10,200. Anton, Inc. is a listed stock. They had purchased the stock on November 10, 2010 for $1,000.

h. $7,000 in federal income tax ,vas ,vithheld during the year.

Complete Kara and Brandon's Form 1040, Schedules A, B, D, and E, Form 8283 and Form 8949. For purposes of this problem, disregard the alternative minimum tax and any credits.

In: Accounting