C++ pointers lab

C++ pointers lab

/*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

"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.


Discount Code: CIPD30



Click ORDER NOW..

order custom paper