Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

C++ c++ language Write a program to read data from the given text file stem.txt. The file has statistics on men and women and the

image text in transcribed
image text in transcribed
C++
c++ language
Write a program to read data from the given text file stem.txt. The file has statistics on men and women and the salary in the STEM fields. The fields in the file are as below: Major Code;Major;Major Category;total men and women;number of men;number of women;salary You need to use the following data types for these fields. Major Code (int) Major (string) Major Category (string) Total (int) number of men (int) number of women (int) Salary (int) 1. There is no need for any user input for this program. Please read the Notes at the end of this document on the next page. 3. You need to read the data from the file and write code for the following functions: 4. Then write main() to test these functions. 1. void openFile (ifstream &inFile); This function takes a file stream variable and opens the file. If file does not exist or cannot open, output error message. 2. void analyze Data (ifstream &infile, int &total, int &men, int &women); This function takes the file stream variable, and 3 other variables to get the total number of people from the total column in the text file, the total number of men and the total number of women from the text file. Print these values in main() after calling this function. 3. void popularMajor (ifstream &in File); This function takes the file stream variable, reads the file from the beginning and finds the most popular major and its major category and outputs to the screen. 4. string highest Paid (ifstream &in File); This function takes the file stream variable, reads the file from the beginning and finds the highest paid major and returns it to main. main() should print this value. Write a program to read data from the given text file stem.txt. The file has statistics on men and women and the salary in the STEM fields. The fields in the file are as below: Major Code;Major;Major Category;total men and women;number of men;number of women;salary You need to use the following data types for these fields. Major Code (int) Major (string) Major Category (string) Total (int) number of men (int) number of women (int) Salary (int) 1. There is no need for any user input for this program. Please read the Notes at the end of this document on the next page. 3. You need to read the data from the file and write code for the following functions: 4. Then write main() to test these functions. 1. void openFile (ifstream &inFile); This function takes a file stream variable and opens the file. If file does not exist or cannot open, output error message. 2. void analyze Data (ifstream &infile, int &total, int &men, int &women); This function takes the file stream variable, and 3 other variables to get the total number of people from the total column in the text file, the total number of men and the total number of women from the text file. Print these values in main() after calling this function. 3. void popularMajor (ifstream &in File); This function takes the file stream variable, reads the file from the beginning and finds the most popular major and its major category and outputs to the screen. 4. string highest Paid (ifstream &in File); This function takes the file stream variable, reads the file from the beginning and finds the highest paid major and returns it to main. main() should print this value

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

Q1) Write a short note on the concept of Fluid as Continuum?

Answered: 1 week ago