Answer to Question #210879 in C++ for Deabende

Question #210879

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-27T14:11:04-0400
#include <fstream>
#include <iostream>
using namespace std;
int main(){
	 fstream new_file;
	 fstream top_common_10_names;
	 fstream least_common_10;
	 new_file.open("babynames2012.txt",ios::in); 
	  top_common_10_names.open("top_common_10 names.txt",ios::out); 
	   least_common_10.open("least common_10 names.txt",ios::out); 
	   if(new_file.is_open()){
	   	string file;
	   	 while(getline(new_file, file)){  
         cout << file<< "\n";  
          top_common_10_names<<file<<endl;
      }
	   	
	   }
}

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