Please do not give solution in image format thanku //I'm having issues with my writeTemps function as it wont display my data. Would you please help me debug this and anything else that might need fixing? I really appreaciate your time!!       *** PROGRAM DESCRIPTION :  *** Read file Temps.txt up to 150 integers, display (five per line), ask user what temp they would like to search for,        use linear search, display where it was found (or wasnt), bubble sort into ascending order, display, compute average temp  * *** *****************/   #include #include using namespace std; const int MAXSIZE=150; void readFile(int [], int&); void writeTemps(int[], int); void findTemp(int[], int); void sortTemps(int[], int); double computeAvg(int[],int); int main() {     int temps[MAXSIZE],count=0;       readFile(temps,count);     writeTemps(temps,count);     findTemp(temps,count);     sortTemps(temps,count);     writeTemps(temps,count);     cout<<"The average temperature is "<> temps[count]) //checks to make sure count is less than maxsize and updates count         count ++;          inFile.close(); //closes file      }   void writeTemps(int temps[], int count) {   for(int i=0; i";        cin >> searchVal;             for (int z = 0; z < count; z++)     { if (temps[z] == searchVal)          {             found = true;             cout << "Temperature was located at index " << z << "!" << endl;          }     }         cout << "Temperature is not found ! !" << endl;         } while (found == false);     return; } void sortTemps(int temps[], int count) {     int t;     bool swap;          do     {         swap = false;                  for (int u = 0; u < count - 1; u++) //swaps the biggest number until it's reached ascending order         {             if (temps[u] > temps[u + 1])             {                 t = temps[u]; //temporarily holds value                 temps[u + 1] = t;                 swap = true;             }         }     } while (swap == true); //loops until swap can no longer occur     return; }   double computeAvg(int temps[], int count) {     int total = 0;     double average;          for (int a = 0; a < count; a++)         total += temps[a]; //adds up each of the integers for a total              average = total / count;          return average; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please do not give solution in image format thanku

//I'm having issues with my writeTemps function as it wont display my data. Would you please help me debug this and anything else that might need fixing? I really appreaciate your time!!

 

 

 

*** PROGRAM DESCRIPTION :

 *** Read file Temps.txt up to 150 integers, display (five per line), ask user what temp they would like to search for,

       use linear search, display where it was found (or wasnt), bubble sort into ascending order, display, compute average temp

 * *** *****************/

 

#include <iostream>

#include <fstream>

using namespace std;

const int MAXSIZE=150;

void readFile(int [], int&);

void writeTemps(int[], int);

void findTemp(int[], int);

void sortTemps(int[], int);

double computeAvg(int[],int);

int main()

{

    int temps[MAXSIZE],count=0;

 

    readFile(temps,count);

    writeTemps(temps,count);

    findTemp(temps,count);

    sortTemps(temps,count);

    writeTemps(temps,count);

    cout<<"The average temperature is "<<computeAvg(temps,count)<<endl;

 

    return 0;

}

 

void readFile(int temps[], int& count)

{

    ifstream inFile;

    inFile.open ("/Users/nadiapinos/Library/Mobile Documents/com~apple~TextEdit/Documents"); //I have to format it like this for Mac

    

    if (!inFile)

    {

        cout << "Error opening file ! !" << endl; //checks to make sure file can be opened

        exit (102);

    }

    

    

    while (count < MAXSIZE && inFile >> temps[count]) //checks to make sure count is less than maxsize and updates count

        count ++;

    

    inFile.close(); //closes file

    

}

 

void writeTemps(int temps[], int count)

{

  for(int i=0; i<count; i++)

  {

    cout << temps [i] << endl; //print temps in array for counted integers

      if (i%5 == 0)cout<<endl; //checks if five are already in line, if so, starts new line

  }

  cout<<endl;

}

 

void findTemp(int temps[], int count)

{

  bool found=false;

  int searchVal;

 

   do //loops until a temperature could be found

   {

       cout << "Please enter the temperature you wish to find ->";

       cin >> searchVal;

       

    for (int z = 0; z < count; z++)

    { if (temps[z] == searchVal)

         {

            found = true;

            cout << "Temperature was located at index " << z << "!" << endl;

         }

    }

        cout << "Temperature is not found ! !" << endl;

    

   } while (found == false);

    return;

}

void sortTemps(int temps[], int count)

{

    int t;

    bool swap;

    

    do

    {

        swap = false;

        

        for (int u = 0; u < count - 1; u++) //swaps the biggest number until it's reached ascending order

        {

            if (temps[u] > temps[u + 1])

            {

                t = temps[u]; //temporarily holds value

                temps[u + 1] = t;

                swap = true;

            }

        }

    } while (swap == true); //loops until swap can no longer occur

    return;

}

 

double computeAvg(int temps[], int count)

{

    int total = 0;

    double average;

    

    for (int a = 0; a < count; a++)

        total += temps[a]; //adds up each of the integers for a total

        

    average = total / count;

    

    return average;

}

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Header Files
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education