Answer to Question #210584 in C++ for thankusomuch

Question #210584

Write a program to read the data from babynames2012.txt and


1-

Print out on another files “top_common_10 names.txt” the top ten popular boys and

girls names.

2-

Print out on another files “least common_10 names.txt” the least ten popular boys

and girls names


In the text file, there are more than 100 baby names but I cannot copy and paste it all because of the word limit. Here is 50 of them.


1 J1 Jacob Sophia
2 Mason Emma
3 Ethan Isabella
4 Noah Olivia
5 William Ava
6 Liam Emily
7 Jayden Abigail
8 Michael Mia
9 Alexander Madison
10 Aiden Elizabeth
11 Daniel Chloe
12 Matthew Ella
13 Elijah Avery
14 James Addison
15 Anthony Aubrey
16 Benjamin Lily
17 Joshua Natalie
18 Andrew Sofia
19 David Charlotte
20 Joseph Zoey
21 Logan Grace
22 Jackson Hannah
23 Christopher Amelia
24 Gabriel Harper
25 Samuel Lillian
26 Ryan Samantha
27 Lucas Evelyn
28 John Victoria
29 Nathan Brooklyn
30 Isaac Zoe
1
Expert's answer
2021-06-25T06:55:59-0400
#include <iostream>
#include <fstream>
#include <string>
using namespace std;




int main () {
    ifstream f1("babynames2012.txt");
    ofstream f2("top_common_10 names.txt");
    ofstream f3("least_common_10 names.txt");
  string text;
  while (getline (fr, text)) {
    f2<<text;
    f3<<text;
  }


    f1.close();
    f2.close();
    f3.close();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS