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
What were the names of Henry VIII's six wives?
timurjin [86]

Answer:

Jane Seymour,Anne Boleyn,Katherine of Aragon,Anne of Cleves,Katherine Howard,Katherine Parr

Explanation:

7 0
1 year ago
Read 2 more answers
One of the ways to create a horizontal navigation menu from an unordered list is to a. set the display property of the element w
Gennadij [26K]

Answer: a. set the display property of the element within each li element to inline

Explanation: In an unordered list, <em>ul</em> signifies the list and <em>li</em> signifies the elements in the list. When you want to display the elements in a list in a horizontal form, for example if you need a horizontal menu, a quick way of doing this is setting the display of li to inline by writing it as follows in css:

<em>li { </em>

<em>Display: inline; </em>

<em>} </em>

This will order the elements in the list into the form of a horizontal menu .

8 0
3 years ago
which explains a method to avoid violation of personal information through phishing? do not carry around your social security ca
snow_lady [41]

The option that explains a method to avoid violation of personal information through phishing is C. never give out credit information to someone who calls you or emails you.

<h3>What is phishing?</h3>

Phishing is a form of social engineering assault that is frequently employed to obtain user information, such as login credentials and credit card details. It happens when an attacker deceives a victim into opening an email, instant message, or text message by disguising themselves as a reliable source.

Therefore, the option that explains a method to avoid violation of personal information through phishing is to never give out credit information to someone who calls you or emails you.

Learn more about phishing on:

brainly.com/question/23021587

#SPJ1

6 0
1 year ago
Which of the following statements is true of alert files?
ozzi

Answer:

They are only generated by Wireshark.

3 0
2 years ago
More registers appear to be a good thing, in terms of reducing the total number of memory accesses a program might require. Give
gulaghasi [49]

Answer:

Following is given the answer step by step:

Explanation:

First of all we will write a program using MARIE that will support the statement: Sum = (A + B) - (C + D). All the necessary comments are given in front of each statement:

Load    A                   # variable A will be loaded

Add     B                  # B will be added to A

Store   Temp1         # A + B will be stored in Temp1

Load    C                  # C will be loaded in memory

Add     D                 # D will be added to C

Store   Temp2         # C + D will ge stored in Temp2

Load    Temp1         # Temp1 will be loaded in the memory

Subt     Temp2         # Temp2(A + B) get subtracted from Temp1(A - B)

Store    Sum             # (A + B) - (C + D) will get stored in Sum.

We can see from above program that memory is accessed 9 times. While if C + D get executed first than memory accesses will be reduced to 7.

Above same program could be written using an architecture of 4 registers:

  • R1
  • R2
  • R3
  • R4

The program is as follows:

Load   R1 , A     #A  will be loaded into R1

Load   R2 , B    # B will be loaded into R2

Add     R1 , R2    # R2 gets added to R1 and the result is stored in R1 (A + B)

Load   R3 , C      # C loaded into R3

Load   R4 , D     # D loaded into R4

Add    R3 , R4   # Value in R4 gets added into R3 and R3 becomes (C + D)

                          #no memory accesses required for this operation

Subt   R1 , R4     #R4 (C + D) gets subtracted from R1 (A + B)

                         #no memory accesses required for this operation

Store  Sum        # The recent value will be stored into Sum

Here memory is accessed 5 times in total.

<h2>I hope it will help you!</h2>
8 0
3 years ago
Other questions:
  • What does subscribing to a website’s RSS feed provide to a subscriber?
    10·1 answer
  • Which best describes the relationship between maximum cost-per-click (max. cpc) bids and ad rank?
    12·1 answer
  • What is a printed copy of computer output called
    10·2 answers
  • Pressing the e key while in edit mode will exit the interaction mode<br><br> true<br><br> false
    7·1 answer
  • g Define memory hierarchy. A. The rate at which information can be transferred from one place to another. B. Ordering storage sy
    8·1 answer
  • 2. From the listing code, please give the block of line numbers for code which are concerned with the following: A) Main functio
    5·1 answer
  • Subana is writing a program which will calculate the mean average of a set of numbers by adding the numbers and dividing the res
    11·2 answers
  • What are some hazards of being an astronomer??
    6·1 answer
  • What is Naptha used for?
    9·2 answers
  • What is the output of this program? age=4 if age &gt;5: print (“more”) else: print (“less”)
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!