1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
MariettaO [177]
3 years ago
6

Implementing the following object oriented programming constructions.1. Member FunctionsReplace the eight supporting output func

tions with member functions in the eight struct s. Name the functions as you like, but name them all the same. Their prototypes inside the structs should all look exactly alike, all with exactly one parameter -- an ostream reference. Modify the function called from the console and file output loops in int main accordingly.2. Stream ManipulatorsReplace the formatting code blocks in each output function with the manipulators provided in the module.3. Conditional OperatorsIf you have not already done so, apply the conditional operator so that there are no more if-else statements to convert tokens to dimensions.#include#include#include#include#include#include#include#includeusing namespace std;struct Square{ double side;};void outputSquare(ostream&, const Square&);struct Rectangle{ double length; double width;};void outputRectangle(ostream&, const Rectangle&);struct Circle{ double radius;};void outputCircle(ostream&, const Circle&);struct Triangle{ double side;};void outputTriangle(ostream&, const Triangle&);struct Cube{ double side;};void outputCube(ostream&, const Cube&);struct Box{ double length; double width; double height;};void outputBox(ostream&, const Box&);struct Cylinder{ double radius; double height;};void outputCylinder(ostream&, const Cylinder&);struct Prism{ double side; double height;};void outputPrism(ostream&, const Prism&);vector parseString(string);int main(){ ifstream infile("Shapes.input.txt"); ofstream fout; fout.open("Shapes.output.txt"); vector bag; vector bagType; string str; vector tokens; while (!infile.eof()) { getline(infile, str); tokens = parseString(str); if (tokens.size() != 0) { if (tokens[0] == "SQUARE") { Square* s = new Square(); if (tokens.size() > 1) s->side = atof(tokens[1].c_str()); else s->side = 0; bag.push_back(s); bagType.push_back(1);}//there's way more shapes, I just had to cut it out to make this question shorter else { if (tokens[0] == "EOF") continue; cout << tokens[0] << " Invalid Object" << endl; } } } for (unsigned int i = 0; i < bag.size(); i++) { if (bagType[i] == 1) { Square* xSquare = reinterpret_cast(bag[i]); Square& ySquare = *xSquare; outputSquare(cout, ySquare); } }//there's way more shapes, I just had to cut it out to make this question shorter for (unsigned int i = 0; i < bag.size(); i++) { if (bagType[i] == 1) { Square* xSquare = reinterpret_cast(bag[i]); Square& ySquare = *xSquare; outputSquare(fout, ySquare); } }//there's way more shapes, I just had to cut it out to make this question shorter for (unsigned int i = 0; i < bag.size(); i++) { if (bagType[i] == 1) { Square* xSquare = reinterpret_cast(bag[i]); delete xSquare; } }//there's way more shapes, I just had to cut it out to make this question shorter fout.close(); return 0;}vector parseString(string str){ stringstream s(str); istream_iterator begin(s), end; return vector(begin, end);}void outputSquare(ostream& fout, const Square& s){ double area, perimeter; area = s.side * s.side; perimeter = 4 * s.side; fout << "SQUARE side = " << s.side << " area = " << fixed << setprecision(2) << area << " perimeter = " << fixed << setprecision(2) << perimeter << "\n";}
Computers and Technology
1 answer:
leonid [27]3 years ago
4 0

Answer:

OMG i can't read that.

Explanation:

You might be interested in
(tco 9) the most common protocol(s) used for sending and retrieving e-mail is(are) _____.
Readme [11.4K]
SMTP = Simple Mail Transport Protool
5 0
4 years ago
Grid computing takes advantage of the available 75% of unused processing power of a computer and links thousands of individual c
11111nata11111 [884]

Answer:

The answer is "Virtual supercomputer"

Explanation:

A supercomputer is a machine with or close to a maximum fastest operating output. It commonly used in science and engineering systems, that have to manage or calculate massive server numbers.

  • A virtual supercomputer is also known as a cloud device.  
  • It gives you to the platform, and provides you a built-in cloud environment, by mixing different virtual servers.
  • Its rebellion is to be used by individuals.

3 0
4 years ago
Type the correct answer in the box. Spell all words correctly.
Kamila [148]

Answer:emphasis

Explanation:

7 0
3 years ago
Which of the following types of tool should be used only on round work, such as rigid or IMC conduit?
Dafna11 [192]
Its C. A pipe wrench 
6 0
3 years ago
Read 2 more answers
Which query will return the entire Gamers table?
Serga [27]

SQL queries can be used to retrieve data from a table.

The query that returns the entire Gamers table is (b) SELECT * FROM Gamers;

To retrieve a data we make use of the SELECT FROM clause

From the question, we understand that all entries of the Gamers table should be returned.

The keyword ALL in SQL is represented with asterisk i.e. *

The table whose data would be retrieved is the Gamers table.

Hence, the required query is: SELECT * FROM Gamers;

Read more about SQL queries at:

brainly.com/question/24223730

7 0
3 years ago
Read 2 more answers
Other questions:
  • Create a class in JobApplicant.java that holds data about a job applicant. Include a name, a phone number, and four Boolean fiel
    13·1 answer
  • How to type in color on clash royale
    15·2 answers
  • âwhen the footer is the last element in a page body, the _____ pseudo-element is used to add a placeholder element after the foo
    8·2 answers
  • What are three situations when recursion is the only option available to address problems?
    10·1 answer
  • intext:"The browser feature which enables tabs to work independently from one another so if one crashes, the others may continue
    12·1 answer
  • What happens if you never confirm your facebook account?
    8·1 answer
  • A personal computer system is composed of the processing unit, graphics board, and keyboard with reliabilities of 0.976, 0.785,
    8·1 answer
  • I just downloaded an update for my laptop. Now, it doesn't give me a notification when the battery is low, and it just shuts off
    6·1 answer
  • What is the multiple source test
    15·1 answer
  • Kathy would like to export a report that she created into an easy-to-use file format that is supported on multiple
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!