Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify the babynames.cpp program so the most common names given to 10 percent of the population are saved to a file output.txt. #include #include #include

Modify the babynames.cpp program so the most common names given to 10 percent of the population are saved to a file output.txt.

#include #include #include

using namespace std; /** Reads name information, prints the name if total >= 0, and adjusts the total. @param in_file the input stream @param total the total percentage that should still be processed */

void process_name(ifstream& in_file, double& total) { string name; int count; double percent; in_file >> name >> count >> percent;

if (in_file.fail()) { return; } // Check for failure after each input if (total > 0) { cout

int main() { ifstream in_file; in_file.open("babynames.txt"); if (in_file.fail()) { return -1; } // Check for failure after opening

double boy_total = 10; double girl_total = 10;

while (boy_total > 0 || girl_total > 0) { int rank; in_file >> rank; if (in_file.fail()) { return 0; }

cout

process_name(in_file, boy_total); process_name(in_file, girl_total);

cout

The code give me this outcome. It looks like it's supposed to be the file content instead.

image text in transcribed

1 Michael Jessica 2 Christopher Ashley 3 Matthew Emily 4 Joshua Sarah 5 Jacob Samantha 6 Nicholas Amanda 7 Brittany 8 Elizabeth 9 Taylor

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions

Question

4. Not sure? Ask them.

Answered: 1 week ago