Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

how do promt the user to input a file and sort the arrays so that it wll output

ID: 3672637 • Letter: H

Question

how do promt the user to input a file and sort the arrays so that it wll output like this:

i cant figure out how to arrange the name and numbers in the correct spot. i know that im being tedious about this and i would like to apoligize because im begginer at this. i just can't grasp the concept well enough. it says that i need to use this function called the parameterized constructor, but i don't know to implement it into the .cpp, the header file, or the main.

Team(string n, int t1, int t2, int t3, int t4, int t5)

Explanation / Answer

//

// File:   FileDataSort.h

// Author: HARE KRISHNA

//

// Created on 28 February, 2016, 2:37 PM

//

#ifndef _FILEDATASORT_H

#define            _FILEDATASORT_H

class Team{

public:

    Team(){

        cout<<"your in default constructor";

    }

    Team(String n,int t1,int t,int t3,int t4,int t5){

        cout<<"parameter constructor";

        this.n =n;

        this.t1 = t1;

        this.t2 = t2;

        this.t3 = t3;

        this.t4=t4;

        this.t5=t5;

    }

   

    void sortProcess(numbers,arraysize){

        double temp; //place holder when values are interchanged

            for (int i = 0; i < arraysize - 1; i++)

                        for (int j = 0; j < arraysize - (i + 1); j++)

                                    if (numbers[j] < numbers[j + 1])

                                    {

                                                temp = numbers[j];

                                                numbers[j] = numbers[j + 1];

                                                numbers[j + 1] = temp;

                                    }

    }

};

int main(){

    double numbers[MAX]; // create a array of doubles at max size

    int arraysize = 5; // this will be our array counter

    ifstream fin;

    String filename;

    cout<<"Enter file name";

    fin.open(filename);

    fin >> numbers[arraysize]; // reads in the first line

    while (fin) // you can also do a eof loop with just the input variable

    {

        arraysize++; // counts how many numbers are in the file;

            fin >> numbers[arraysize]; // reads in the next lines

    }

    numbers[arraysize] = '';

    cout << "Unsorted Numbers: " << endl;

    for (int i = 0; numbers[i] != ''; i++){

        cout << endl << numbers[i];

    }

cout << endl;

    int t1,t2,t3,t4,t5;

    t1 = numbers[0]

    t2 = numbers[1];

    t3 = numbers[2];

    t4 = numbers[3];

    t5 = numbers[4];

    //default condtructor

    Team tdata ;

    //parametrised constructor

    tdata('n',t1,t2,t3,t4,t5);

    // array pass to function

    tdata.sortProcess(numbers,arraysize);

   }

#endif /* _FILEDATASORT_H */