Description
/*Lab 1
Write the function() getData, outputCities(), reverse(), find(), delete(), insertion sort()
*/
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#define MAX 1000
using namespace std;
//Function Prototypes
int main()
{
//Variable declarations
string city[MAX]; //holds the name, XX for each city
double costIndex[MAX]; //cost of living index for that city
int num; //number of cities in study
ifstream inFile;
ofstream outFile;
//Open file
inFile.open("cities.txt");
//Tests if file exists
if (inFile.fail())
{
//error to console
cout << "Error: File not found!" << endl;
system("pause");
exit(1);
}
outFile.open("output.txt");
//Function to input namd of city and cost index; returns number of cities in study
num = getData(inFile, city, costIndex);
inFile.close();
//Function to reverse the elements in the original arrays
//Cities will be ordered Z - A in descending order
//Function to output name of city, cost index formatted in two tabular columns
printAll(outFile, city, costIndex, num);
//Ask the user for a name of a city, call a function to find that city, and from main
// output the cost of living index of the phrase "No Such City" (linear search is okay)
//Ask the user for a name of a city and delete that city and its cost of index
//Using insertion sort sort the cities from high to low based on cost of living index
//Function to output name of city, cost index formatted in two tabular columns
printAll(outFile, city, costIndex, num);
outFile.close();
system("pause");
return 0;
}
Rubric for Lab 1
1) Must have your name, title of lab, and your e-mail as a comment at the very top of your code
2) Must have your name, title of lab, and your e-mail printed to the output file
3) All output is to be directed to file
4) (30 pts) Must write Pre:, Pose: & Purpose for each function: getData(), output(), reverse(), search(), delete(), insertionSort()
5) Output must be in tabular form meaning that strings are left-justified and numbers are right-justified. Numerical output is to be with one digit accuracy to the right of the decimal point.
6) Upload precisely one .cpp file and the output as a text file.
7) Define no classes - procedural code only
Unformatted Attachment Preview
Purchase answer to see full attachment

Explanation & Answer

Attached.
your name
title of lab
your e-mail
RESULTS FOR REVERSED DATA :
Name of City
Cost of Index
Yuma, AZ
Youngstown-Warren, OH
York County, PA
Yakima, WA
Wooster, OH
Winston-Salem, NC
Winchester, VA-WV
Wilmington, NC
Wilmington, DE
Williamsport-Lycoming, Co, PA
Wichita, KS
Wichita, Falls, TX
Weatherford, TX
Wausau, WI
Waterloo-Cedar, Falls, IA
Washington-Arlington-Alexandria, DC-VA
Waco, TX
Vero, Beach-Indian, River, FL
Vancouver, WA
Valdosta, GA
Tyler, TX
Twin Falls, ID
Tuscaloosa, AL
Tupelo, MS
Tulsa, OK
Tucson, AZ
Truckee-Nevada, County, CA
Troy-Miami, County, OH
Topeka, KS
Thomasville-Lexington, NC
Temple, TX
Tampa, FL
Tacoma, WA
Syracuse, NY
Sumter, SC
Stillwater, OK
Staunton-Augusta, County, VA
Stamford, CT
St. Paul, MN
St. Louis, MO-IL
St. Joseph, MO
St. George, UT
St. Cloud, MN
Springfield, MO
Springfield, IL
Spokane, WA
South, Bend, IN
Slidell-St., Tammany, Parish, LA
Sioux, Falls, SD
Sierra, Vista, AZ
Shreveport-Bossier, City, LA
Sheboygan, WI
Seguin, TX
Seattle, WA
Savannah, GA
107.4
92.6
98.4
99.8
99.5
98.5
104.6
108
108.1
103.5
90.5
91.9
95.9
100
89.5
107.9
81.8
109.1
96.9
111.8
92.7
95.5
104.9
91.1
91.9
97.2
132.2
96.4
92.9
105.5
83.7
96.3
111.3
98.6
103.4
95.5
98.3
121.8
107
98.4
95.4
99.9
101.7
93.2
89.7
92.4
91.3
95.1
91.5
96.5
95.2
94.3
90.7
115.1
94.7
Sarasota, FL
San Marcos, TX
San Jose, CA
San Francisco, CA
San Diego, CA
San Antonio, TX
San Angelo, TX
Salt Lake City, UT
Salina, KS
Sacramento, CA
Round,Rock, TX
Roswell, NM
Rockford, IL
Rochester, NY
Rochester, MN
Roanoke, VA
Riverside, City, CA
Rio Rancho, NM
Richmond, VA
Richmond, IN
Reno-Sparks, NV
Raleigh, NC
Quincy, IL
Pueblo, CO
Pryor, Creek, OK
Providence, RI
Prescott-Prescott Valley, AZ
Portland, OR
Portland, ME
Ponca, City, OK
Plattsburgh, NY
Plano, TX
Pittsfield, MA
Pittsburgh, PA
Phoenix, AZ
Philadelphia, PA
Peoria, IL
Pascagoula, MS
Paris, TX
Panama, City, FL
Palm Springs, CA
Paducah, KY
Orlando, FL
Orange County, CA
Omaha, NE
Olympia, WA
Oklahoma City, OK
Odessa, TX
Oakland, CA
Norman, OK
Newark-Elizabeth, NJ
New York, (Queens), NY
New York (Manhattan), NY
New York(Brooklyn), NY
New Haven, CT
Nassau County, NY
Nashville-Franklin, TN
Nacogdoches, TX
Myrtle Beach, SC
Muskogee, OK
Murfreesboro-Smyrna, TN
Muncie, IN
Morristown, TN
Morgantown, WV
107.7
88.7
115.3
111.9
105.5
84.9
89.3
100.1
86.9
114.7
81.9
105.6
92.6
94.6
89.6
89.7
104.9
92
103.6
83.3
105.4
104.2
97.4
100.5
95
113.4
95.2
105.8
101.8
94.8
98.9
101.3
115
104.1
108.1
124.9
93.4
101
93.6
93.7
111.5
94.8
97.8
104.5
92
107.4
92.9
91.2
116.8
95.3
111.6
128.3
154.3
130.6
117.9
123
91.7
91
105.7
98
94.3
91
91.6
93.9
Montgomery, AL
Monroe, LA
Mobile, AL
Missoula, MT
Minot, ND
Minneapolis, MN
Milwaukee-Waukesha, WI
Midland, TX
Middlesex-Monmouth, NJ
Miami-Dade, County, FL
Memphis, TN
McAll...
