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
Determine the minimum radius of a horizontal circular curve for a route having a 70 mph design speed, super-elevation (e) 3%, an
patriot [66]

Answer:

a) Rmin ≈ 52 m

b) D = 110.184°

c) Lc ≈ 59 m

d) PT Station = 2827+12.37

PT Station = 2827+78.63

Explanation:

a) Given

v = 70 mph = (70 mph)(1,609 m/1 mile)(1 h/3600 s) = 31.286 m/s

e = 3% = 0.03

f = 0.12

a) We can use the equation

Rmin = v²/(127*(e + f))

⇒ Rmin = (31.286)²/(127*(0.03 + 0.12))

⇒ Rmin = 51.38 m ≈ 52 m

b) We can use the equation

D = 5729.578/R  ⇒  D = 5729.578/52

⇒  D = 110.184°

c) We apply the formula

Lc = R*Δ/57.3

If  Δ = 65°  we have

Lc = 52*65/57.3

⇒ Lc = 58.98 m ≈ 59 m

d) If the PI is station 2827+45.50 we get the tangent length T as follows:

T = R*tan(Δ/2)

⇒ T = 52*tan(65/2) = 33.13 m

then, the station of the PC will be

PC Station = PI - T

⇒ PC Station = (2827+45.50) - (0+33.13) = 2827+12.37

and the station of the PT will be

PT Station = PI + T

⇒ PT Station = (2827+45.50) + (0+33.13) = 2827+78.63

3 0
4 years ago
5. If a pilot wants to accelerate, which force
Murljashka [212]

Answer:

Thrust

Explanation:

If the pilot wants to accelerate the aircraft, the aircraft needs more power to produce more thrust. The aircraft will go faster when the amount of thrust is greater than the amount of drag.

3 0
3 years ago
If 20 kg of iron, initially at 12 °C, is added to 30 kg of water, initially at 90 °C, what would be the final temperature of the
rjkz [21]

Answer:

final temperature of the combined system T = 84.78°C

Explanation:

Given data

mass of iron ( m1 )   = 20 kg

temperature iron ( t1 ) =  12 °C

mass of water ( m2 ) = 30 kg

temperature of water ( t2 )   =  90 °C

To find out

final temperature of the combined system

solution

we know the energy requirement formula to rise the temp

energy = mass × specific heat  × change in temperature  

we combine both system so both energy will be added

and

we know specific heat of iron ( c1 ) = 0.450 kJ/kg

and specific heat of water ( c2 ) = 4.186 kJ/kg

4.186 joule/gram °C

now combine both energy

energy = mass, m1 × specific heat, c1  × change in temperature, T - t1 + mass, 2 × specific heat, c2  × change in temperature, T - t2

energy = 20 × 0.450  × T - 12  + 30 × 4.186 × T -90

(20)(0.45)(T−12)=(30)(4.186)(90−T)

final temperature of the combined system T = 84.78°C

5 0
3 years ago
Two resistors, with resistances R1 and R2, are connected in series. R1 is normally distributed with mean 65 and standard deviati
Sedbober [7]

Answer:

n this question, we are asked to find the probability that  

R1 is normally distributed with mean 65  and standard deviation 10

R2 is normally distributed with mean 75  and standard deviation 5

Both resistor are connected in series.

We need to find P(R2>R1)

the we can re write as,

P(R2>R1) = P(R2-R1>R1-R1)

P(R2>R1) = P(R2-R1>0)

P(R2>R1) = P(R>0)

Where;

R = R2 - R1

Since both and are independent random variable and normally distributed, we can do the linear combinations of mean and standard deviations.

u = u2-u1

u = 75 - 65 = 10ohm

sd = √sd1² + sd2²

sd = √10²+5²

sd = √100+25 = 11.18ohm

Now we will calculate the z-score, to find  P( R>0 )

Z = ( X -u)/sd

the z score of 0 is

z = 0 - 10/11.18

z= - 0.89

4 0
4 years ago
As the junior engineer at the Mesabi Range Hydraulic Engineering Company located in Ely, Minnesota, you have been tasked with de
katen-ka-za [31]

yes it will

Explanation:

5 0
4 years ago
Other questions:
  • The equation of motion is not valid without the assumption of an inertial frame. a) True b)- false
    5·2 answers
  • A speaker's knowledge of how he or she wants to affect the audience will be helpful in choosing the right information and influe
    7·1 answer
  • Technician A says independent shops are not affiliated with vehicle manufacturers, but it is easy for technicians who work in th
    8·1 answer
  • That there is evidence of electrical failure given that there was a gas leak. Enter your answer in accordance to the item b) of
    13·2 answers
  • Recovery Assignment 3: Engineering ethics 1 1/2 page typed
    6·1 answer
  • N DevOps, high levels of automation are expected, which increases productivity. Which fact illustrates this productivity increas
    8·1 answer
  • A demand factor of _____ percent applies to a multifamily dwelling with ten units if the optional calculation method is used.
    14·1 answer
  • If a soil has e=0.72, moisture content = 12% and Gs=2.72, find the weight of water in KN/m3 to be added to make the soil saturat
    6·1 answer
  • For a small company it's usually best to keep the corporate and brand image as___ as possible​
    9·1 answer
  • A Hartnell governor has two rotating balls, of mass 2.7 kg each. The ball radius is 125 mm in the mean position when the
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!