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
Wittaler [7]
3 years ago
6

TV show information can either keep track of the number of viewers per show or the name of a show. Information is kept in a file

(see sample files below). If the first line of the file says Show, we should store the names of the shows. If the first line of the file says Viewer, we should store the number of viewers per show.
Create a class to complete the program below.
int main(int argc, char** argv) Tv_show_info Tv_show_info show_names(argv[2]);
int n=viewers.info.at(0);
std::string s=show_names.info.at(0);

Sample input file 2: Viewer Sample input file 1: Show Stranger Things Game of Thrones Black Mirror 34 100

its not provided, we are to recreate it. but this is what i made..

template
class Tv_show_info
{
public:
// template
Tv_show_info(string & file):
filename{file}
{
ifstream myfile {filename};
vectorinfo;
T lines;
while (getline(myfile,lines))
{
info.push_back(lines);
}
}
private:
string filename;
};

Computers and Technology
1 answer:
Elza [17]3 years ago
3 0

Answer:

See explaination for Program source code.

Explanation:

The program source code below.

#include <iostream>

#include <fstream>

#include <vector>

using namespace std;

class Show

{

private:

string title;

int viewers;

public:

Show()

{

this->title = "";

this->viewers = 0;

}

Show(string title, int viewers)

{

this->title = title;

this->viewers = viewers;

}

string getTitle(){ return this->title; }

int getViewers(){ return this->viewers; }

};

int main()

{

vector<Show> shows;

vector<string> titles;

vector<int> viewers;

ifstream inFile1("file1.txt");

ifstream inFile2("file2.txt");

string line1, line2;

if(!inFile1.is_open() || !inFile2.is_open())

{

cout << "Either of the files could not be found!\n";

exit(0);

}

getline(inFile1, line1);

if(line1.compare("Show") == 0)

{

while(getline(inFile1, line1))

{

titles.push_back(line1);

}

inFile1.close();

}

getline(inFile2, line2);

if(line2.compare("Viewer") == 0)

{

while(getline(inFile2, line2))

{

viewers.push_back(stod(line2));

}

inFile2.close();

}

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

{

shows.push_back(Show(titles[i], viewers[i]));

}

// display all the show details

cout << "\nALL SHOWS:\n----------\n";

for(Show show : shows)

{

cout << "Title: " << show.getTitle() << ", Number of viewers: " << show.getViewers() << endl;

}

cout << endl;

return 0;

}

See attachment for output

You might be interested in
Why is special code needed for &lt;?
IRINA_888 [86]
The guy above is right!!!
3 0
3 years ago
How to get answers on Microsoft form any code or hacks u can guv that'll be nice
KonstantinChe [14]

Simple, really. No hacks required. Just study and you'll do fine.

3 0
3 years ago
There are two tasks that need to be done with a hard drive before the operating system can use it. What are they?
PolarNik [594]
First you Format Hard drive to remove all data then you will have to set up a storage partition for the new Operating System can load start up instructions. Usually your OS will prompt you for permission and order to establish partition storage size.
8 0
3 years ago
A(n) ____ is a named storage location that can hold a data value.
malfutka [58]
A(n) -input- is a named storage location that can hold a data value.
3 0
3 years ago
The governor of New York that he has directed the state's Division of Criminal Justice Services to gather DNA from the broadest
kobusy [5.1K]

Answer:

Database

Explanation:

Database.

The State’s DNA database is a database of DNA profiles that can be made public or private and can be used in the analysis of genetic fingerprinting for criminology. There are certain laws that come with how DNA databases are supposed to be handled.

7 0
3 years ago
Other questions:
  • Discuss how and why video game hardware affects game design and where you think the next generation of platforms will change tho
    9·1 answer
  • Where does the term for a star network describe? A) a network for Department of Defense scientists to share data about the stars
    13·2 answers
  • Here's a thought: Why does your Brainly ranking keep going down?
    6·2 answers
  • Write a program that first reads in the name of an input file and then reads the input file using the file.readlines() method. T
    14·1 answer
  • How do you compare text on different pages of a document?
    14·1 answer
  • What is an aptitude assessment that matches students with study programs at specific colleges and universities?
    7·2 answers
  • Write a program (using functions) starting from directives to compute and display the transpose of a matrix of dimension m x n.
    13·1 answer
  • Disuss the roles of hardware,software and databases in regard to computer based information systems
    7·1 answer
  • Hello guys please help me <br>list and identify the components of computer ​
    15·1 answer
  • By the mid-1990s, how did revenue generated from video games compare to revenue generated from movies?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!