Blog

Coursehelp
February 6, 2019
QUESTION : No Comments

Your boss at Contact PR, a hip midsized public relations agency, is concerned

Your boss at Contact PR, a hip midsized public relations agency, is concerned that the youngest employee generation may be “over-sharing” on Facebook. Two supervisors have complained that they spotted inappropriate photos on Facebook posted by a small group of Millennials on the company payroll. This group of twenty-somethings is close-knit. Its members maintain friendships outside the office and in cyberspace. They are smart and plugged in, but they seem to have trouble recognizing boundaries of age and authority. They party every weekend, which is code for a lot of drinking, marijuana use, and even salacious escapades-all of which the young workers generously document with smartphone cameras on the spot and occasionally in real time. Sometimes they share snarky comments about their workplace, such as “Rough day at work” or “Talked to the most idiotic client ever!” On top of that, the young people think nothing of friending their colleagues and supervisors. Their “friends” rank in the hundreds; some in the group have exceeded 1,000 friends on Facebook.

Contact PR has embraced cutting-edge technology because the management believes that information sharing and collaboration tools can lead to networking opportunities and, if used correctly, to increased productivity. The company maintains a permissive stance toward Internet use, but concern is growing that the young people are headed for trouble. The abuses continue despite the company’s comprehensive Internet and social media use policy, which was widely disseminated. Probably the biggest risk Contact PR fears is the leaking of confidential information on social networking sites. The managers also complain that the Millennials spend too much time on Facebook during work hours. Your boss is becoming impatient. After several meetings, the management decides to disallow Facebook use during work hours and to caution all employees against dangerous breaches of company policy and social media netiquette.

YOUR TASK: Draft an email to be sent by your boss, Judy L. Shea, Director, Human Resources. Your message should remind all employees about the existing social networking policy and tactfully yet clearly announce the end of Facebook use at the office. The prohibition is effective immediately. Your message should also warn about the pitfalls of over-sharing online.

Expert Answer

From :

Judy L. Shea,

Director, Human Resources

To : The Employees

Subject : No Facebook on the company’s dime

It has come to management’s attention that our employees are spending . . .

OR
OR

Have a Comment on this Question?

Questions viewed by other students


  • QUESTION : (Solved) : Code Ve Made Include Include Include Double Positivequad Double Double B Double C Double P Q35339391 . . .

    1. Roots of Quadratic Equation Write a program to compute the roots of a quadratic equation ar2 + br + c-= 0 using the well-k

    This is the code I’ve made:

    #include<stdlib.h>
    #include<stdio.h>
    #include<math.h>

    double positiveQuad(double a, double b, double c) {
    double pos;
    pos = (-b + (sqrt(pow(b, 2) – 4 * a * c))) / 2 * a;
    return pos;
    }

    double negativeQuad(double a, double b, double c) {
    double neg;
    neg = (-b – (sqrt(pow(b, 2) – 4 * a * c))) / 2 * a;
    return neg;
    }

    int main(int argc, char **argv) {
    double a;
    double b;
    double c;

    printf(“Enter the values of a, b, and c: “);
    scanf(“%lf %lf %lfn”, &a, &b, &c);

    if (a == 0) {
    printf(“Output: Can’t divide by zero”);
    } else if (positiveQuad(a, b, c) == negativeQuad(a, b, c)) {
    printf(“Output: Root is %0.2f”, positiveQuad(a, b, c));
    } else if ((a > 0) & (b < 0)) {
    printf(“Output: Would result in a complex root”);
    } else {
      
    printf(“Output: Roots are %0.2f and %0.2f”, positiveQuad(a, b, c),negativeQuad(a, b, c));

    }

    return 0;
    }

    ==============================

    for some reason 2 18 0 for a b c, I would get -36 for mynegative root when it’s suppose to be -9. What could be wrong?

    1. Roots of Quadratic Equation Write a program to compute the roots of a quadratic equation ar2 + br + c-= 0 using the well-known quadratic formula: 2a Your program will prompt the user for the values: a, b, c and output each real root However, for “invalid” input (a 0 or values that would result in complex roots), the program will instead output a message that informs the user why the inputs are invalid with a specific reason). Your output should look like the following Enter the values of a, b, and c: 2 18 0 Output: Roots are 0.00 and -9.00 Enter the values of a, b, and c: 1 -2 3 Output: Would result in a complex root Show transcribed image text

    Expert Answer


    . . .


    view full answer
  • QUESTION : (Solved) : Code Using Visual Studio C Comment Section Understanding Code Q34565087 . . .

    Code using the visual studio in C++ and comment on each sectionto understanding the code.

    1. Introduction This assignment will review the fundamentals of using structures to represent data. It will also familiarize you with the basics of input and output in C++. You will model two- dimensional polygons as a series of points, thus nesting variables of one structure type inside another. Your main program will manage a list of these polygons, as well as giving you a facility to test if a point is inside one of the polygons One common algorithm for testing if a point lies inside a polygon is to draw a horizontal line to the right of each point, extending that line to infinity, and count how many times that line intersects polygon edges. If that result is odd, the point is inside the polygon Your program should implement a version of this algorithm Figure1: Points both inside and outside a polygon. Points, c, d, and e are inside the polygon--lines extended to the right of each point intersect an odd number of polygon edges 2. Deliverables You should submit five files for this assignment: prog1_main.cpp: Source file containing your main function. Point.h: Header file containing definition of Point structure and prototypes of relevant functions. Point.cpp: Source file containing definitions of Point functions Polygon.h: Header file containing definition of Polygon structure and prototypes of relevant functions Polygon.cpp: Source file containing definitions of Polygon functions Submit a single archive file (zip only) containing all five h and cpp files to the Program 1 assignment on Blackboard. Ensure your file names match the names specified above. Failure to meet this specification will reduce your grade.3. Specifications The main program (prog1_main.cpp) recognizes four different single-letter commands, most of which call functions described in Point.h or Polygon.h and defined in the · A, ‘a: Add a Polygon to the array of Polygons, which can contain up to 10 o When this command is entered, the program should prompt the user to enter corresponding source file: elements the number of vertices in the Polygon (with a maximum of 20 vertices), then read all of those Points and store them in the Polygon structure. P, ‘p: Print the entire list of Polygons as a collection of Points. For each Polygon, four coordinates should be shown per line. * T, t: Test whether a Point is inside one of the Polygons o When this command is entered, the program should prompt the user to enter a Point (x-coordinate first), then an index into the Polygon array ( . X, x: Exit the program Point.h contains the definition of the Point structure, which consists of two coordinates, x and y. We used this Point structure definition in an in-class example struct Point i double x; double y; // x coordinate // Y coordinate Point.h should also contain prototypes for any functions related to this type, which you must properly define in Point.cpp. You are required to write at least the following tWo functions (but are welcome to add any others you find necessary) void printPoint (Point &pt) Print the x and y coordinates of the Point referenced by the argument p using the following format: (x, y) (for example, (3.14, -5.2)) You do not have to specify a certain number of decimal places, but should ensure that the x- and y-coordinates are enclosed by parentheses and separated by a comma void readPoint (Point &pt) Read x and y coordinates from the user input into the Point referenced by the argument p. This function should prompt the user for coordinates3. Specifications The main program (prog1_main.cpp) recognizes four different single-letter commands, most of which call functions described in Point.h or Polygon.h and defined in the . A, a: Add a Polygon to the array of Polygons, which can contain up to 10 o When this command is entered, the program should prompt the user to enter corresponding source file elements the number of vertices in the Polygon (with a maximum of 20 vertices), then read all of those Points and store them in the Polygon structure P, p: Print the entire list of Polygons as a collection of Points. For each Polygon, . four coordinates should be shown per line . T, t: Test whether a Point is inside one of the Polygons o When this command is entered, the program should prompt the user to enter a Point (x-coordinate first), then an index into the Polygon array ( ‘X, X: Exit the program · Point.h contains the definition of the Point structure, which consists of two coordinates, x and y. We used this Point structure definition in an in-class example struct Point ( double x; double y; // x coordinate // Y coordinate Point.h should also contain prototypes for any functions related to this type, which you must properly define in Point.cpp. You are required to write at least the following two functions (but are welcome to add any others you find necessary) void printPoint (Point &pt); Print the x and y coordinates of the Point referenced by the argument p using the following format: (x, y) (for example, (3.14, -5.2)) You do not have to specify a certain number of decimal places, but should ensure that the x- and y-coordinates are enclosed by parentheses and separated by a comma void readPoint (Point &pt) Read x and y coordinates from the user input into the Point referenced by the argument p. This function should prompt the user for coordinates3. Specifications (continued) Polygon.h contains the definition of the Polygon structure, which can contain up to 20 Point structures representing the vertices of the Polygon. Its up to you to define this structure, but note that: Your Polygon structure must contain, at a minimum, an array of Point structures . and a variable indicating the actual number of vertices in the Polygon. Defining a bounding box for the Polygon (the minimum and maximum x and y values across all vertices) makes it easier to quickly determine if many points are . outside the Polygon-anything outside the bounding box is outside the Polygon . Polygon edges are defined to be between consecutive pairs of points stored in the Polygon structure. For example, if the user enters a triangle, that Polygon will contain three Points, with edges between the 1s/2nd Points, 2n/3rd Points, and 3rd/1st Points Polygon.h should also contain prototypes for any functions related to this type, which you must properly define in Polygon.cpp. You are_required to_write at least the following two functions (but are welcome to add any others you find necessary): void printPoly ( example, given a polygon with 6 vertices, the output of this function might be Polygon «pol); Print all of the vertices of the polygon in order, with at most 4 vertices per line. For Vertices: (0.9, 0.8), (0, 2) void readPoly (Polygon &p01); Prompt for and read the number of vertices in the Polygon, then read all of those Points4. Hints Point-in-polygon algorithm: A few pointers on how to test for a point inside a polygon: As noted above, you can quickly determine if a point is outside a polygon if its outside the box determined by the minimum and maximum x- and y-coordinates. To implement the algorithm in Section 1, note the following: o The infinite line to the right of a given test point has the same y-coordinate greater than or equal to the initial point. o Testing if this imaginary line crosses a polygon edge therefore requires you to Check that the y value for the test point is between the y values of the . Check that the x value for the test point is to the left of the line connecting do the following for each edge: edge endpoints. those edge endpoints (which essentially requires you to find the point on the line that has the same y value as your test point). o Remember, a polygon edge is defined by consecutive pairs of Point structures inside the Polygon structure.5. Test Cases Your output should match these test cases exactly for the given input values. I will use these test cases in grading of your assignments, but will also generate additional cases that will not be publicly available. Note that these test cases may not cover all possible program outcomes. You should create your own tests to help debug your code and ensure proper operation for all possible inputs The test cases were generated in Xcode, so lve copied and pasted the output below rather than showing a screenshot of the output window. User input is underlined, although it wont be when you run the program Enter command (A | P | T l X): A Enter number of vertices: 4 Point 0--Enter x and v coordinates: 0 0 Point 1-Enter x and y coordinates: 5 Point 2--Enter x and y coordinates: 76 Point 3--Enter x and y coordinates 4 -1 Enter command (A | P | T | X): A Enter number of vertices: 6 Point 0--Enter x and y coordinates: 3 2 Point 1--Enter x and y coordinates: 5.6 7.8 Point 2--Enter x and y coordinates 4 3 Point 3--Enter x and y coordinates -1 -1 Point 4--Enter x and y coordinates 0.9 0.8 Point 5-Enter x and v coordinates: 0 2 Enter command (A | P | T | X) : P POLYGON 0 Vertices: POLYGON 1: Vertices: (0.9, 0.8), (0, 2) Enter command (APT IX): T Point to test--Enter x and y coordinates: 2 3 Enter polygon number: 0 (2, 3) is inside polygon 0 Enter command (A | P | T | X) : T Point to test--Enter x and y coordinates: 2 3 Enter polygon number: 1 (2, 3) is outside polygon 15. Test Cases (continued) Enter command (A | P | T 1 X) : T Point to test-Enter x and y coordinates: Enter polygon number: 0 (-0.5, -0.5) is outside polygon 0 Enter command (A | P | T 1 X) : T Point to test--Enter x and y coordinates 0.5-0.5 Enter polygon number: 1 (-0.5, -0.5) is outside polygon 1 Enter command (A I PI TI X): x

    1. Introduction This assignment will review the fundamentals of using structures to represent data. It will also familiarize you with the basics of input and output in C++. You will model two- dimensional polygons as a series of points, thus nesting variables of one structure type inside another. Your main program will manage a list of these polygons, as well as giving you a facility to test if a point is inside one of the polygons One common algorithm for testing if a point lies inside a polygon is to draw a horizontal line to the right of each point, extending that line to infinity, and count how many times that line intersects polygon edges. If that result is odd, the point is inside the polygon Your program should implement a version of this algorithm Figure1: Points both inside and outside a polygon. Points, c, d, and e are inside the polygon–lines extended to the right of each point intersect an odd number of polygon edges 2. Deliverables You should submit five files for this assignment: prog1_main.cpp: Source file containing your main function. Point.h: Header file containing definition of Point structure and prototypes of relevant functions. Point.cpp: Source file containing definitions of Point functions Polygon.h: Header file containing definition of Polygon structure and prototypes of relevant functions Polygon.cpp: Source file containing definitions of Polygon functions Submit a single archive file (zip only) containing all five h and cpp files to the “Program 1″ assignment on Blackboard. Ensure your file names match the names specified above. Failure to meet this specification will reduce your grade. 3. Specifications The main program (prog1_main.cpp) recognizes four different single-letter commands, most of which call functions described in Point.h or Polygon.h and defined in the · A’, ‘a”: Add a Polygon to the array of Polygons, which can contain up to 10 o When this command is entered, the program should prompt the user to enter corresponding source file: elements the number of vertices in the Polygon (with a maximum of 20 vertices), then read all of those Points and store them in the Polygon structure. ‘P, ‘p’: Print the entire list of Polygons as a collection of Points. For each Polygon, four coordinates should be shown per line. * ‘T’, ‘t’: Test whether a Point is inside one of the Polygons o When this command is entered, the program should prompt the user to enter a Point (x-coordinate first), then an index into the Polygon array ( . “X’, ‘x’: Exit the program Point.h contains the definition of the Point structure, which consists of two coordinates, x and y. We used this Point structure definition in an in-class example struct Point i double x; double y; // x coordinate // Y coordinate Point.h should also contain prototypes for any functions related to this type, which you must properly define in Point.cpp. You are required to write at least the following tWo functions (but are welcome to add any others you find necessary) void printPoint (Point &pt) Print the x and y coordinates of the Point referenced by the argument p using the following format: (x, y) (for example, (3.14, -5.2)) You do not have to specify a certain number of decimal places, but should ensure that the x- and y-coordinates are enclosed by parentheses and separated by a comma void readPoint (Point &pt) Read x and y coordinates from the user input into the Point referenced by the argument p. This function should prompt the user for coordinates 3. Specifications The main program (prog1_main.cpp) recognizes four different single-letter commands, most of which call functions described in Point.h or Polygon.h and defined in the . ‘A’, ‘a’: Add a Polygon to the array of Polygons, which can contain up to 10 o When this command is entered, the program should prompt the user to enter corresponding source file elements the number of vertices in the Polygon (with a maximum of 20 vertices), then read all of those Points and store them in the Polygon structure ‘P’, ‘p’: Print the entire list of Polygons as a collection of Points. For each Polygon, . four coordinates should be shown per line . ‘T’, ‘t’: Test whether a Point is inside one of the Polygons o When this command is entered, the program should prompt the user to enter a Point (x-coordinate first), then an index into the Polygon array ( ‘X’, X”: Exit the program · Point.h contains the definition of the Point structure, which consists of two coordinates, x and y. We used this Point structure definition in an in-class example struct Point ( double x; double y; // x coordinate // Y coordinate Point.h should also contain prototypes for any functions related to this type, which you must properly define in Point.cpp. You are required to write at least the following two functions (but are welcome to add any others you find necessary) void printPoint (Point &pt); Print the x and y coordinates of the Point referenced by the argument p using the following format: (x, y) (for example, (3.14, -5.2)) You do not have to specify a certain number of decimal places, but should ensure that the x- and y-coordinates are enclosed by parentheses and separated by a comma void readPoint (Point &pt) Read x and y coordinates from the user input into the Point referenced by the argument p. This function should prompt the user for coordinates 3. Specifications (continued) Polygon.h contains the definition of the Polygon structure, which can contain up to 20 Point structures representing the vertices of the Polygon. It’s up to you to define this structure, but note that: Your Polygon structure must contain, at a minimum, an array of Point structures . and a variable indicating the actual number of vertices in the Polygon. Defining a “bounding box” for the Polygon (the minimum and maximum x and y values across all vertices) makes it easier to quickly determine if many points are . outside the Polygon-anything outside the bounding box is outside the Polygon . Polygon edges are defined to be between consecutive pairs of points stored in the Polygon structure. For example, if the user enters a triangle, that Polygon will contain three Points, with edges between the 1s/2nd Points, 2n/3rd Points, and 3rd/1st Points Polygon.h should also contain prototypes for any functions related to this type, which you must properly define in Polygon.cpp. You are_required to_write at least the following two functions (but are welcome to add any others you find necessary): void printPoly ( example, given a polygon with 6 vertices, the output of this function might be Polygon «pol); Print all of the vertices of the polygon in order, with at most 4 vertices per line. For Vertices: (0.9, 0.8), (0, 2) void readPoly (Polygon &p01); Prompt for and read the number of vertices in the Polygon, then read all of those Points 4. Hints Point-in-polygon algorithm: A few pointers on how to test for a point inside a polygon: As noted above, you can quickly determine if a point is outside a polygon if it’s outside the box determined by the minimum and maximum x- and y-coordinates. To implement the algorithm in Section 1, note the following: o The “infinite line” to the right of a given test point has the same y-coordinate greater than or equal to the initial point. o Testing if this imaginary line crosses a polygon edge therefore requires you to Check that the y value for the test point is between the y values of the . Check that the x value for the test point is to the left of the line connecting do the following for each edge: edge endpoints. those edge endpoints (which essentially requires you to find the point on the line that has the same y value as your test point). o Remember, a polygon edge is defined by consecutive pairs of Point structures inside the Polygon structure. 5. Test Cases Your output should match these test cases exactly for the given input values. I will use these test cases in grading of your assignments, but will also generate additional cases that will not be publicly available. Note that these test cases may not cover all possible program outcomes. You should create your own tests to help debug your code and ensure proper operation for all possible inputs The test cases were generated in Xcode, so l’ve copied and pasted the output below rather than showing a screenshot of the output window. User input is underlined, although it won’t be when you run the program Enter command (A | P | T l X): A Enter number of vertices: 4 Point 0–Enter x and v coordinates: 0 0 Point 1-Enter x and y coordinates: 5 Point 2–Enter x and y coordinates: 76 Point 3–Enter x and y coordinates 4 -1 Enter command (A | P | T | X): A Enter number of vertices: 6 Point 0–Enter x and y coordinates: 3 2 Point 1–Enter x and y coordinates: 5.6 7.8 Point 2–Enter x and y coordinates 4 3 Point 3–Enter x and y coordinates -1 -1 Point 4–Enter x and y coordinates 0.9 0.8 Point 5-Enter x and v coordinates: 0 2 Enter command (A | P | T | X) : P POLYGON 0 Vertices: POLYGON 1: Vertices: (0.9, 0.8), (0, 2) Enter command (APT IX): T Point to test–Enter x and y coordinates: 2 3 Enter polygon number: 0 (2, 3) is inside polygon 0 Enter command (A | P | T | X) : T Point to test–Enter x and y coordinates: 2 3 Enter polygon number: 1 (2, 3) is outside polygon 1 5. Test Cases (continued) Enter command (A | P | T 1 X) : T Point to test-Enter x and y coordinates: Enter polygon number: 0 (-0.5, -0.5) is outside polygon 0 Enter command (A | P | T 1 X) : T Point to test–Enter x and y coordinates 0.5-0.5 Enter polygon number: 1 (-0.5, -0.5) is outside polygon 1 Enter command (A I PI TI X): x Show transcribed image text 1. Introduction This assignment will review the fundamentals of using structures to represent data. It will also familiarize you with the basics of input and output in C++. You will model two- dimensional polygons as a series of points, thus nesting variables of one structure type inside another. Your main program will manage a list of these polygons, as well as giving you a facility to test if a point is inside one of the polygons One common algorithm for testing if a point lies inside a polygon is to draw a horizontal line to the right of each point, extending that line to infinity, and count how many times that line intersects polygon edges. If that result is odd, the point is inside the polygon Your program should implement a version of this algorithm Figure1: Points both inside and outside a polygon. Points, c, d, and e are inside the polygon–lines extended to the right of each point intersect an odd number of polygon edges 2. Deliverables You should submit five files for this assignment: prog1_main.cpp: Source file containing your main function. Point.h: Header file containing definition of Point structure and prototypes of relevant functions. Point.cpp: Source file containing definitions of Point functions Polygon.h: Header file containing definition of Polygon structure and prototypes of relevant functions Polygon.cpp: Source file containing definitions of Polygon functions Submit a single archive file (zip only) containing all five h and cpp files to the “Program 1” assignment on Blackboard. Ensure your file names match the names specified above. Failure to meet this specification will reduce your grade.
    3. Specifications The main program (prog1_main.cpp) recognizes four different single-letter commands, most of which call functions described in Point.h or Polygon.h and defined in the · A’, ‘a”: Add a Polygon to the array of Polygons, which can contain up to 10 o When this command is entered, the program should prompt the user to enter corresponding source file: elements the number of vertices in the Polygon (with a maximum of 20 vertices), then read all of those Points and store them in the Polygon structure. ‘P, ‘p’: Print the entire list of Polygons as a collection of Points. For each Polygon, four coordinates should be shown per line. * ‘T’, ‘t’: Test whether a Point is inside one of the Polygons o When this command is entered, the program should prompt the user to enter a Point (x-coordinate first), then an index into the Polygon array ( . “X’, ‘x’: Exit the program Point.h contains the definition of the Point structure, which consists of two coordinates, x and y. We used this Point structure definition in an in-class example struct Point i double x; double y; // x coordinate // Y coordinate Point.h should also contain prototypes for any functions related to this type, which you must properly define in Point.cpp. You are required to write at least the following tWo functions (but are welcome to add any others you find necessary) void printPoint (Point &pt) Print the x and y coordinates of the Point referenced by the argument p using the following format: (x, y) (for example, (3.14, -5.2)) You do not have to specify a certain number of decimal places, but should ensure that the x- and y-coordinates are enclosed by parentheses and separated by a comma void readPoint (Point &pt) Read x and y coordinates from the user input into the Point referenced by the argument p. This function should prompt the user for coordinates
    3. Specifications The main program (prog1_main.cpp) recognizes four different single-letter commands, most of which call functions described in Point.h or Polygon.h and defined in the . ‘A’, ‘a’: Add a Polygon to the array of Polygons, which can contain up to 10 o When this command is entered, the program should prompt the user to enter corresponding source file elements the number of vertices in the Polygon (with a maximum of 20 vertices), then read all of those Points and store them in the Polygon structure ‘P’, ‘p’: Print the entire list of Polygons as a collection of Points. For each Polygon, . four coordinates should be shown per line . ‘T’, ‘t’: Test whether a Point is inside one of the Polygons o When this command is entered, the program should prompt the user to enter a Point (x-coordinate first), then an index into the Polygon array ( ‘X’, X”: Exit the program · Point.h contains the definition of the Point structure, which consists of two coordinates, x and y. We used this Point structure definition in an in-class example struct Point ( double x; double y; // x coordinate // Y coordinate Point.h should also contain prototypes for any functions related to this type, which you must properly define in Point.cpp. You are required to write at least the following two functions (but are welcome to add any others you find necessary) void printPoint (Point &pt); Print the x and y coordinates of the Point referenced by the argument p using the following format: (x, y) (for example, (3.14, -5.2)) You do not have to specify a certain number of decimal places, but should ensure that the x- and y-coordinates are enclosed by parentheses and separated by a comma void readPoint (Point &pt) Read x and y coordinates from the user input into the Point referenced by the argument p. This function should prompt the user for coordinates
    3. Specifications (continued) Polygon.h contains the definition of the Polygon structure, which can contain up to 20 Point structures representing the vertices of the Polygon. It’s up to you to define this structure, but note that: Your Polygon structure must contain, at a minimum, an array of Point structures . and a variable indicating the actual number of vertices in the Polygon. Defining a “bounding box” for the Polygon (the minimum and maximum x and y values across all vertices) makes it easier to quickly determine if many points are . outside the Polygon-anything outside the bounding box is outside the Polygon . Polygon edges are defined to be between consecutive pairs of points stored in the Polygon structure. For example, if the user enters a triangle, that Polygon will contain three Points, with edges between the 1s/2nd Points, 2n/3rd Points, and 3rd/1st Points Polygon.h should also contain prototypes for any functions related to this type, which you must properly define in Polygon.cpp. You are_required to_write at least the following two functions (but are welcome to add any others you find necessary): void printPoly ( example, given a polygon with 6 vertices, the output of this function might be Polygon «pol); Print all of the vertices of the polygon in order, with at most 4 vertices per line. For Vertices: (0.9, 0.8), (0, 2) void readPoly (Polygon &p01); Prompt for and read the number of vertices in the Polygon, then read all of those Points
    4. Hints Point-in-polygon algorithm: A few pointers on how to test for a point inside a polygon: As noted above, you can quickly determine if a point is outside a polygon if it’s outside the box determined by the minimum and maximum x- and y-coordinates. To implement the algorithm in Section 1, note the following: o The “infinite line” to the right of a given test point has the same y-coordinate greater than or equal to the initial point. o Testing if this imaginary line crosses a polygon edge therefore requires you to Check that the y value for the test point is between the y values of the . Check that the x value for the test point is to the left of the line connecting do the following for each edge: edge endpoints. those edge endpoints (which essentially requires you to find the point on the line that has the same y value as your test point). o Remember, a polygon edge is defined by consecutive pairs of Point structures inside the Polygon structure.
    5. Test Cases Your output should match these test cases exactly for the given input values. I will use these test cases in grading of your assignments, but will also generate additional cases that will not be publicly available. Note that these test cases may not cover all possible program outcomes. You should create your own tests to help debug your code and ensure proper operation for all possible inputs The test cases were generated in Xcode, so l’ve copied and pasted the output below rather than showing a screenshot of the output window. User input is underlined, although it won’t be when you run the program Enter command (A | P | T l X): A Enter number of vertices: 4 Point 0–Enter x and v coordinates: 0 0 Point 1-Enter x and y coordinates: 5 Point 2–Enter x and y coordinates: 76 Point 3–Enter x and y coordinates 4 -1 Enter command (A | P | T | X): A Enter number of vertices: 6 Point 0–Enter x and y coordinates: 3 2 Point 1–Enter x and y coordinates: 5.6 7.8 Point 2–Enter x and y coordinates 4 3 Point 3–Enter x and y coordinates -1 -1 Point 4–Enter x and y coordinates 0.9 0.8 Point 5-Enter x and v coordinates: 0 2 Enter command (A | P | T | X) : P POLYGON 0 Vertices: POLYGON 1: Vertices: (0.9, 0.8), (0, 2) Enter command (APT IX): T Point to test–Enter x and y coordinates: 2 3 Enter polygon number: 0 (2, 3) is inside polygon 0 Enter command (A | P | T | X) : T Point to test–Enter x and y coordinates: 2 3 Enter polygon number: 1 (2, 3) is outside polygon 1
    5. Test Cases (continued) Enter command (A | P | T 1 X) : T Point to test-Enter x and y coordinates: Enter polygon number: 0 (-0.5, -0.5) is outside polygon 0 Enter command (A | P | T 1 X) : T Point to test–Enter x and y coordinates 0.5-0.5 Enter polygon number: 1 (-0.5, -0.5) is outside polygon 1 Enter command (A I PI TI X): x

    Expert Answer


    . . .


    view full answer
  • QUESTION : (Solved) : Code Well Documented High Level Comments Also Codes Include Synopsis Algorithm Used Perfor Q34283565 . . .

    You will modify the subroutine in mul.s, replacing the two instructions that reside there with your solution The Specification . The register %edi will contain the argurnent a. ·The register %esi will contain the argument b. . The register %eax will carry the return value, the product of a and b. . You may use registers %rax, %rcx, %rax, %rsi, %rdi, %r8, %r9, %r10 and %r 11 as scratch registers. i.e., you may modify their values without penalty. Plan your register usage accordingly! You may not modify the values of registers %rbx, %rbp, %rsp, %r12, %r13, %r14 and %r15. You may not modify the values of any external memory locations.

    Your code should be well documented with high-level comments.Also, your codes include a synopsis of the algorithm you used toperform the multiplication,please. Thanks!

    The code provided:

    a) mul.s

       .globl times
    times:
       mov %edi, %eax # remove these two lines before
       imull %esi, %eax # you start writing your code

       ret

    b)main.c

    #include <stdio.h>

    unsigned times(unsigned, unsigned);

    void main () {
    unsigned a = 6;
    unsigned b = 7;
    printf(“The product of %u and %u is %u. “, a, b, times(a,b));
    return;
    }

    We were unable to transcribe this imageYou will modify the subroutine in mul.s, replacing the two instructions that reside there with your solution The Specification . The register %edi will contain the argurnent a. ·The register %esi will contain the argument b. . The register %eax will carry the return value, the product of a and b. . You may use registers %rax, %rcx, %rax, %rsi, %rdi, %r8, %r9, %r10 and %r 11 as scratch registers. i.e., you may modify their values without penalty. Plan your register usage accordingly! You may not modify the values of registers %rbx, %rbp, %rsp, %r12, %r13, %r14 and %r15. You may not modify the values of any external memory locations. Show transcribed image text

    Expert Answer


    . . .


    view full answer
  • QUESTION : (Solved) : Code Want Always Execute Whether Exception Thrown Placed Block Try Catch Finally Program E Q30657048 . . .

    The code you want to always execute, whether an exception isthrown or not, is placed in the ____ block.

    try
    catch
    finally
    if

    If a program experiences an unhandled exception, the programterminates.

    True
    False

    All exceptions inherit from the base ____ class.

    SystemException
    Exception
    ApplicationException
    BaseException

    Run-time errors are typically easy to fix.

    True
    False

    Using the debugger built into Visual Studio allows you to placea marker that causes the code to pause execution. This is ____.

    an event
    a breakpoint
    a watch
    an exception

    The two types of errors are compile and run-time errors.

    True
    False

    Expert Answer


    . . .


    view full answer
  • QUESTION : (Solved) : Code Want Add Products Case 2 Show Products Must Constant Program Anytime User Chose Show Q31407728 . . .

    In this code I want to add some products under case 2 ( showall products ) and it must be constant In the program anytime whenthe user chose ( show all products )All products must appear and then the user can chooseanyone

    “””””””””””””””””””””””””””””””””””””””””””””””””#include <iostream>#include <string>#include <iomanip>
    using namespace std;
    //struture to to store product detailsstruct product{
    string name;
    int quantity;
    float price;
    };
    //Function to show prduct detailsvoid show_products(product products[]){
    //Checking is product is not emptyif (products[0].name.empty()){cout << “nYou have not added any product yet.” <<endl;return;}
    //Displaying Formated Messagescout << “nnAll Products”;cout <<“n——————————————————————————–n”;cout << left << setw(18) << “ProductNumber”<< left << setw(30) << “Name”<< left << setw(15) << “Quantity”<< left << setw(15) << “Unit Price”;cout <<“n——————————————————————————–n”;
    //Displaying Product Descriptionfor (int i = 0; i < 30; i++){if (products[i].name.empty())break;cout << left << setw(18) << i + 1<< left << setw(30) <<products[i].name<< left << setw(15) <<products[i].quantity<< left << setw(15) << products[i].price<< “n”;}cout <<“——————————————————————————–n”;}
    //Driver Functionint main(){//Data Variableint x, choice, i = 0;product products[30];
    /* Do-While LoopIterate until user press 6*/do{//Displaying Menucout << “n1. Add products” << endl<< “2. Show all products” << endl<< “3. Update a product” << endl<< “4. Delete a product” << endl<< “5. Purchase a product” << endl<< “6. Exit” << endl<< “Enter your choice: “;
    //Taking choicecin >> choice;
    //Switching for choiceswitch (choice){case 1: //Case for adding productscout<<“n”;cout << “Enter product name: “;cin >> ws; // Clean whitespacesgetline(cin, products[i].name);cout << “Enter product quantity: “;cin >> products[i].quantity;cout << “Enter unit price: “;cin >> products[i].price;i++;break;
    case 2: //Case for displaying products detailsshow_products(products);break;
    case 3: //Case for update a productcout << “Enter product number: “;cin >> x;cout << “Enter product name: “;cin >> ws; // Clean whitespacesgetline(cin, products[x – 1].name);cout << “Enter product quantity: “;cin >> products[x – 1].quantity;cout << “Enter unit price: “;cin >> products[x – 1].price;break;
    case 4: //Case for delete a productcout << “Enter product number: “;cin >> x;for (int y = x; y < 30; y++){cout << “Product Name: ” << products[y – 1].name<< endl;
    if (products[y].name.empty()){products[y – 1].name = “”;break;}products[y – 1] = products[y];}
    break;
    case 5: //Case for purchase a productcout<<“n”;cout << “Enter product number: “;cin >> x;x = x – 1;
    //traversing in product arrayfor(int y = 0; y<30; y++){//checking if entered number is same as prduct numberif(x == y){//Displaying matched product detailscout<<“Product Found!”;cout<<“nProduct Name : “<<products[x].name;cout<<“nProduct Price :”<<products[x].price;cout<<“nProduct Quantity :”<<products[x].quantity;
    //Procedure to purchaseint quan;mark://Taking input of quantitycout<<“nnEnter Quantity to purchased : “;cin>>quan;
    //Checking if quantity availableif(quan < products[x].quantity){cout<<“Product Purchased”;products[x].quantity = products[x].quantity – quan;}else{cout<<“Quantity Not Available”;goto mark;}}}
    break;
    case 6:break;
    default: //Deafault Messagecout <<“—————————————–“<<endl;cout << “You have not chosen any choice yet”<<endl;cout << “Enter any key to return to the main menu”<<endl;cin >> ws;break;
    }
    } while (choice != 6);
    return 0;}

    Expert Answer


    . . .


    view full answer