1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
aliya0001 [1]
3 years ago
13

Using OOP, write a C++ program that will read in a file of names. The file is called Names.txt and should be located in the curr

ent directory of your program. Read in and store the names into an array of 30 names. Sort the array using the selection sort or the bubblesort code found in your textbook. List the roster of students in ascending alphabetical order. Projects using global variables or all code is in main() will result in a grade submission of 0. List of names in Names.txt: Jackie Sam Bill Tom Mary Paul Zev Barb John Sharon Dana Dominic Steven Padro Katey Kathy Darius Angela Mimi Jesse Kenny Lynn Hector Brittany Jenn Joe Chloe Geena Sylvia Dean
Engineering
2 answers:
Katen [24]3 years ago
7 0

Answer: This doesn't work fully, but it's a start. Good Luck

#include <iostream>

#include <fstream>

#include <string>

#include <cstdlib>

using namespace std;

class People

{

private:

const static int SIZE = 30;  

string names[SIZE];  

int birth_years[SIZE];  

int count;  

void sort();  

void display();  

public:

People();

void simulate();

};

People::People()

{

count = 0;

// open both files

ifstream namesFile, birthyearsFile;

namesFile.open("Names.txt");

birthyearsFile.open("BirthYear.txt");

while (!namesFile.eof() && !birthyearsFile.eof() && count < SIZE)

{

 getline(namesFile, names[count]);  

 birthyearsFile >> birth_years[count];  

 count++;  

}

// files open failed, exit the program

if (namesFile.fail() || birthyearsFile.fail())

{

 cout << "Unable to open input file(s). Terminating" << endl;

 exit(1);

}

//close the files

namesFile.close();

birthyearsFile.close();

sort();

display();

}

void People::sort()

{

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

{

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

 {

  if (names[j] > names[j + 1])

  {

   string tempName = names[j];

   names[j] = names[j + 1];

   names[j + 1] = tempName;

   int tempYear = birth_years[j];

   birth_years[j] = birth_years[j + 1];

   birth_years[j + 1] = tempYear;

  }

 }

}

}

void People::display()

{

cout << "Alphabetical Roster of Names: " << endl;

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

{

 cout << names[i] << "\t" << birth_years[i] << endl;

}

cout << endl;

}

void People::simulate()

{

int year;

cout << endl << "Names by Birth Year" << endl;

// input the birth year

cout << "Please enter the birth year: ";

cin >> year;

// loop that continues until valid input has been read

while (cin.fail() || year < 1995 || year > 2005)

{

 cin.clear();  

 cin.ignore(100, '\n');  

 cout << "Invalid birth year entered, try again: ";  

 cin >> year;

}

bool found = false;  

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

{

 if (birth_years[i] == year)  

 {

  if (!found)  

  {

   cout << endl << "For the birth year of " << year << ":" << endl;

   found = true;

  }

  // display the name

  cout << names[i] << endl;

 }

}

// no name with birth year found

if (!found)

 cout << endl << "No names with the birth year " << year << "." << endl;

cout << "End of results" << endl;

}

int main()

{

People people;  

people.simulate();  

return 0;

}

Explanation:

Tanzania [10]3 years ago
5 0
Not really sure sorry for not being able to help
You might be interested in
Explain why veracity, value, and visualization can also be said to apply to relational databases as well as Big Data.
Hatshy [7]

Answer:

Veracity, Value and Visualization are not only the characteristics of Big Data but are also the characteristics of relational databases. Veracity of data is issue with smallest data stores this is the reason that it is important in relation...

5 0
3 years ago
A square isothermal chip is of width w 5 mm on a side and is mounted in a substrate such that its side and back surfaces are wel
Lynna [10]

Answer:

a) 0.35 W

b) 5.25 W

Explanation:

Given that

Width of the chip, W = 5 mm

The environment temperature, T(∞) = 15° C

Surface temperature, T(s) = 85° C

The initial convection heat coefficient, h1 = 200 W/m².K

The final convection heat coefficient, h2 = 3000 W/m².K

See attachment for solution

6 0
3 years ago
Why do the quadrants in coordinate plane go anti-clockwise?.
tia_tia [17]

Answer:

Quadrants are counter-clockwise because angles are measured counter-clockwise; and angles are measured counter-clockwise so that Cross Product of unit vector in X direction with that in the Y direction has to be the unit vector in the Z direction (coming towards us from the origin).

Explanation:

7 0
2 years ago
Georgia Tech is committed to creating solutions to some of the world’s most pressing challenges. Tell us how you have improved o
Kaylis [27]

Answer:

Georgia Tech is committed to WGAR 53566 THE ANSWER IS JELLY IS KING AND THE JELLY IS KING AND  hope to improve the human condition in your community.

Explanation:

6 0
3 years ago
A cooling system load is 96,000 BTUh sensible. How much chilled air is required to satisfy the load if the system is designed fo
Natalija [7]

Answer:

For 20^{\circ} - 5.556 lb/s

For 15^{\circ} - 7.4047 lb/s

Solution:

As per the question:

System Load = 96000 Btuh

Temperature, T = 20^{\circ}

Temperature rise, T' = 15^{\circ}

Now,

The system load is taken to be at constant pressure, then:

Specific heat of air, C_{p} = 0.24 btu/lb ^{\circ}F

Now, for a rise of 20^{\circ} in temeprature:

\dot{m}C_{p}\Delta T = 96000

\dot{m} = \frac{96000}{C_{p}\Delta T} = \frac{96000}{0.24\times 20} = 20000 lb/h = \frac{20000}{3600} = 5.556 lb/s

Now, for 15^{\circ}:

\dot{m}C_{p}\Delta T = 96000

\dot{m} = \frac{96000}{C_{p}\Delta T} = \frac{96000}{0.24\times 15} = 26666.667 lb/h = \frac{26666.667}{3600} = 7.4074 lb/s

4 0
3 years ago
Other questions:
  • Thermoplastics burn upon heating. a)-True b)- false?
    14·1 answer
  • What is EL Niño?
    9·1 answer
  • a) Give a brief description of the type of DC motor that operates with its field windings running in Series with the armature an
    10·1 answer
  • The title block generally contains ________.
    12·1 answer
  • Rain falls on a 1346 acre urban watershed at an intensity of 1.75 in/hr for a duration of 1 hour. The catchment land use is 20%
    10·1 answer
  • : A cyclical load of 1500 lb is to be exerted at the end of a 10 in. long aluminium beam (see Figure below). The bar must surviv
    6·1 answer
  • PLEASE HELP WITH THIS ASAP! Thanks
    6·1 answer
  • Match the scenario to the problem-solving step it represents.
    7·1 answer
  • Drop the name below the corresponding part. (Look at the picture above to answer)
    5·1 answer
  • A thin aluminum sheet is placed between two very large parallel plates that are maintained at uniform temperatures T1 = 900 K, T
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!