Question: Please fix my C++ code so I get the expected output. #include #include #include using namespace std; const int MAX_SIZE = 10; // Function to

Please fix my C++ code so I get the expected output.

Please fix my C++ code so I get the expected output. #include#include #include using namespace std; const int MAX_SIZE = 10; // Function

#include  #include  #include  using namespace std; const int MAX_SIZE = 10; // Function to read names and weights from file int readData(string names[], int weightsInPounds[]); // Function to return pounds in kilograms float poundsToKilograms(int pounds); // Function to calculate and store weight in kilograms void calculateWeightInKilograms(int weightsInPounds[], float weightsInKilograms[], int size); // Function to print names and weights in a tabular format void printData(string names[], int weightsInPounds[], int size); // Function to calculate low, high and average weights void processData(int weightsInPounds[], int size, int &lowWeight, int &highWeight, float &averageWeight); // Function to print low, high and average weights void printProcessedData(int lowWeight, int highWeight, float averageWeight); // Function to sort data in ascending order by weight using bubble sort void sortData(string names[], int weightsInPounds[], int size); int main() { // Declare arrays and variables string names[MAX_SIZE]; int weightsInPounds[MAX_SIZE]; int size = 0; int lowWeight, highWeight; float averageWeight; size = readData(names, weightsInPounds); // Check if the arrays are empty if (size == 0) { return 0; } cout > filename; // Open file ifstream inFile(filename); // Check if file opened successfully or not if (!inFile) { cout > names[size]; if (inFile.eof()) break; inFile >> weightsInPounds[size]; size++; } // Close file inFile.close(); return size; } // Function to return pounds in kilograms float poundsToKilograms(int pounds) { return pounds / 2.2; } // Function to calculate and store weight in kilograms void calculateWeightInKilograms(int weightsInPounds[], float weightsInKilograms[], int size) { for (int i = 0; i  highWeight) highWeight = weightsInPounds[i]; averageWeight += weightsInPounds[i]; } averageWeight /= size; } // Function to print low, high and average weights void printProcessedData(int lowWeight, int highWeight, float averageWeight) { cout  weightsInPounds[j + 1]) { // Swap weights int weight = weightsInPounds[j]; weightsInPounds[j] = weightsInPounds[j + 1]; weightsInPounds[j + 1] = weight; // Swap corresponding names string name = names[j]; names[j] = names[j + 1]; names[j + 1] = name; } } } }

Your output does not contain 4:Bad file name 0/5 Input abc.txt Youroutput Enter file name: Error: abc.txt does not exist Your output does not Error: abc.txt does not exists. 5:Blank File contain 0/5 Input blank.txt Youroutput Enter file name: Error: there is no data in the file Your output does not contain Error: there is no data in the file

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!