write a C++ program to analyze a small subset of the data solved

write a C++ program to analyze a small subset of the data solved





(Absolutely no two-dimensional arrays may be used)

Purpose:
Analyze and summarize the data collected on United States universities.

In this program you will write a C++ program to analyze a small subset of the data that has been collected. See file universities.txt .

Use precisely seven parallel arrays: one for name of university, one for state, one for city, one for yearly tuition, one for enrollment,
one for average freshman retention, and one for the percent of students who graduate within six years. Note that the percentage of
student accepted is not stored. An output file is opened in main() and remains open until the end of the execution.

Input:

Write a function to input the name of each university, the two-letter abbreviation for the state, the city, tuition, enrollment, average
freshman retention rate, percent that graduate within six years.


Repeat until end of file. Assume a maximum of 1000 universities. Use getline(file, string name) to input text with spaces. You will
find a very mischievous ‘\n’ character to deal with both after the name of the university and at the end of the five numerical values.
You will enjoy knowing about file.ignore().

Output: Write a separate function to output to the file all universities with name of university, state, tuition, enrollment, percentage
retention for freshman, and percentage that have graduated after six years for each. NOTE THAT THE CITY IS NOT OUTPUT.

Processing:
Call the output function to output to a file all data in the original order.

Write a separate function to compute and return the average tuition for all universities. Do not output from this function but return
the value and print it out to the screen from main().

Write a function to ask the user for maximum he/she can pay for tuition. List to the screen the name only of all schools with that
amount or less for tuition. Output is from within the function.


Write a function to prompt the user for a two-letter abbreviation for a state. Output to the file from this function all information for
colleges within that state or output message “No colleges in XX state in the list”.

Write one and only one function to return the subscript of the university with the lowest tuition. There is no output in this
function. Do not assume a sorted array. In main(), the name(s) of the university or universities with this low tuition and the amount
of the tuition are output to the screen.

Use a selection sort to sort universities by enrollment in ascending order. This is written as a separate function with no output.

Write the sorted array to the file.

THEME ISSUES: one-dimensional arrays, if statements, file input, file output, searching, sorting

Absolutely no two-dimensional arrays, no structures and no menu function.

Sample of the output before sorting (this is what display after the output function is called) :


University
State Tuition Enrollment
%Fresh
%Graduate

Succeed
in six years
Princeton University
NJ 41820.00
8014
98.00%
97.00%
Harvard University
MA 43938.00


19882
97.00%
97.00%
Yale University
CT 45800.00
12109
99.00%
98.00%
Columbia University
NY 51008.00
23606
99.00%
96.00%
Stanford University
CA 44757.00
18136
98.00%
96.00%
University of Chicago
IL 48253.00
12539
99.00%
93.00%
Massachusetts Institute of Technology
MA 45016.00
11301


98.00%
93.00%
. . .


How should you do this? Follow these steps carefully!!!!!!!
STEP 1
Write main() and call getData() function which only opens file. Debug.
STEP 2
Complete getdata(). Debug.
STEP 3
Write output function. Output is directed to the output file and NOT the screen. Debug.
STEP 4
Write the function to compute the average of tuition at all schools. Output this value to the screen
from main(). Debug.
STEP 5
Write a function that will output the name only of each university where the tuition is less than or equal
to the given amount. Output to the screen.
STEP 6
Write a function to prompt the user for a two-letter abbreviation for a state. Output to the file from this
function all information for colleges within that state or output message “No colleges in XX state in the
list”. Debug.
STEP 7
Write one and only one function to return the subscript of the university with the lowest tuition. There
is no output in this function. Do not assume a sorted array. In main(), the name(s) of the university or
universities with this low tuition and the amount of the tuition are output to the screen.
STEP 8


Write a separate function using the selection sort to sort universities by enrollment in ascending order.
Debug


Checkpoints
Possible
Documentation throughout to explain general outline of program.
5
Minimum of three (3) comments in each function
(Purpose: Pre: Post:)
Include name, e-mail, and lab# as comment and printed to output
Function main() which implements each step outlined in the processing section of the lab write-up.
5
Input function fills array for names plus four numerical arrays. It should return the number of
5
universities.
Output function
5
Function to compute the average of tuition at all schools
4
Function to output to screen universities where tuition is less than or equal to given amount.
4
Function to prompt the user for a two-letter abbreviation for a state. Output to the file from this function
4
all information for colleges within that state or output message “No colleges in XX state in the list”.
Write one and only one function to return the subscript of the university with the lowest tuition. There is


4
no output in this function. Do not assume a sorted array. In main() the name(s) of the university or
universities with this low tuition and the amount of the tuition are output to the screen.
Function using the selection sort to sort universities by enrollment in ascending order.
4
Totals
40

 
Powered by