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
Nancy ate a 500 Cal lunch. Neglecting efficiency issues (i.e., assuming 100% conversion of energy to work), to what height could
VladimirAG [237]

Answer:

4265.04\ \text{m}

2.38\times 10^{10}\ \text{W}

Explanation:

PE = Energy of food = 500 cal = 500\times4184=2.092\times10^6\ \text{J}

m = Mass of object = 50 kg

g = Acceleration due to gravity = 9.81\ \text{m/s}^2

Potential energy of food is given by

PE=mgh\\\Rightarrow h=\dfrac{PE}{mg}\\\Rightarrow h=\dfrac{2.092\times 10^6}{50\times 9.81}\\\Rightarrow h=4265.04\ \text{m}

Nancy could raise the weight to a maximum height of 4265.04\ \text{m}.

Mass of H_2 used per year = 25\times 10^{9}\ \text{kg/year}

Energy of H_2 = \dfrac{30\times10^9}{1000}=30\times 10^6\ \text{J/kg}

Power

P=25\times 10^{9}\ \text{kg/year}\times 30\times 10^6\ \text{J/kg}\\\Rightarrow P=7.5\times 10^{17}\ \text{J/year}\\\Rightarrow P=\dfrac{7.5\times 10^{17}}{365.25\times 24\times 60\times 60}\\\Rightarrow P=2.38\times 10^{10}\ \text{W}

The power requirement is 2.38\times 10^{10}\ \text{W}.

6 0
3 years ago
What is the area enclosed by the cycle area of the Carnot cycle illustrating on a T-s diagram?
gayaneshka [121]

Answer:

Heat

Explanation:

Carnot cycle:

  Carnot cycle is the ideal cycle for all working engine .Carnot cycle all processes are reversible.It have fore process Out of two are constant temperature process and other two are isentropic process(reversible adiabatic).

We know that area under T-s diagram represents the heat.

So Q=\int Tds

From cycle we can say that

q_{in}=T_2\left ( s_2-s_1 \right )

q_{out}=T_1\left ( s_2-s_1 \right )

4 0
4 years ago
People learn best in different ways. By combining all the group presentations, your class will explain how they see the optical
DENIUS [597]

Answer:

People learn best in different ways. By combining all the group presentations, your class will explain how they see the optical illusion in a way that every student will be able to understand. Which presentation helped you understand how you saw the optical illusion best?

I cont under stand

4 0
3 years ago
Read 2 more answers
A 75-hp motor that has an efficiency of 91.0% is worn-out and is replaced by a motor that has a high efficiency 75-hp motor that
damaskus [11]

Answer:

the reduction in the heat gain is 2.8358 kW

Given that;

Shaft outpower of a motor  = 75 hp = ( 75 × 746 ) = 55950 W

Efficiency of motor  = 91.0% = 0.91

High Efficiency of the motor  = 95.4% = 0.954

now, we know that, efficiency of motor is defined as;  =  /

where   is the electric input given to the motor

so

=  /

we substitute

= 55950 W / 0.91

= 61483.5 W

= 61.4835 kW

now, the electric input given to the motor due to increased efficiency will be;

=  /

we substitute

= 55950 W / 0.954

= 58647.79 W

= 58.6477 kW

so the reduction of the heat gain of the room due to higher efficiency will be;

Q =  -

we substitute

Q = 61.4835 kW - 58.6477 kW

Q = 2.8358 kW

Therefore, the reduction in the heat gain is 2.8358 kW

Explanation:  i hope this answer your question if this is wrong or correct please let me know.also no trying to be rude but can you sent me like a thanks?

8 0
3 years ago
Problema sobre programacion orientada a objetos!!
Alecsey [184]

Answer:If they are used to top-down programming or functional programming, which treats elements of code as precise mathematical functions, it takes .

Explanation:

8 0
3 years ago
Other questions:
  • Suppose a steam locomotive is rated at 7500 horsepower. If its efficiency is 6%, how much wood must be burned in a 3-hour trip?
    11·1 answer
  • Compare a series circuit powered by six 1.5-volt batteries to a series circuit powered by a single 9-volt battery. Make sure the
    6·1 answer
  • Create a program named IntegerFacts whose Main() method declares an array of 10 integers.Call a method named FillArray to intera
    12·1 answer
  • An office worker claims that a cup of cold coffee on his table warmed up to 80°C by picking up energy from the surrounding air,
    7·2 answers
  • Consider a circular array implementation of a queue contained using an array of size 6. I repeat x times (where x is 1 + the thi
    13·1 answer
  • While walking across campus one windy day, an engineering student speculates about using an umbrella as a "sail" to propel a bic
    7·1 answer
  • Giving away points hope they help with your questions
    14·1 answer
  • Describe and compare the characteristics of (a) proportional control, (b) proportional plus integral control, (c) proportional p
    14·1 answer
  • about edubrainly. it seems it takes the questions from this website, C&amp;P them, and also try's to get you to have viruses. ca
    9·1 answer
  • what is a home that has its own roof, foundation, and a wall that extends from the roof through the foundation
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!