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
Steam enters an adiabatic condenser (heat exchanger) at a mass flow rate of 5.55 kg/s where it condensed to saturated liquid wat
Evgen [1.6K]

Answer:

The minimum mass flow rate will be "330 kg/s".

Explanation:

Given:

For steam,

m_{s}=5.55 \ kg/s

\Delta h=2491 \ kg/kj

For water,

\Delta T=10^{\circ}C

(Cp)_{w}=4.184 \ kJ/kg^{\circ}C

They add energy efficiency as condenser becomes adiabatic, with total mass flow rate of minimal vapor,

⇒  m_{s}\times (\Delta h)=M_{w}\times(Cp)_{w}\times \Delta T

On putting the estimated values, we get

⇒  5.55\times 2491=M_{w}\times 4.184\times 10\\

⇒  13825.05=M_{w}\times 41.84

⇒  M_{w}=330 \ kg/s

7 0
3 years ago
In a much smaller model of the Gizmo apparatus, a 5 kg mass drops 86 mm (0.086 m) and raises the temperature of 1 gram of water
Orlov [11]

Answer:

The amount of energy transferred to the water is 4.214 J

Explanation:

The given parameters are;

The mass of the object that drops = 5 kg

The height from which it drops = 86 mm (0.086 m)

The potential energy P.E. is given by the following formula

P.E = m·g·h

Where;

m = The mass of the object = 5 kg

g = The acceleration de to gravity = 9.8 m/s²

h = The height from which the object is dropped = 0.086 m

Therefore;

P.E. = 5 kg × 9.8 m/s² × 0.086 m = 4.214 J

Given that the potential energy is converted into heat energy, that raises the 1 g of water by 1°C, we have;

The amount of energy transferred to the water = The potential energy, P.E. = 4.214 J.

6 0
3 years ago
Mahamad Siddiqui sent false emails and letters of recommendation on behalf of individuals without their permission to nominate h
shusha [124]

Mahamad Siddiqui sent false emails and letters of recommendation on behalf of individuals without their permission to nominate himself for the Waterman Award at the National Science Foundation. His earlier emails were offered where he had solicited letters were offered as evidence. Siddiqui claimed that content of earlier emails was hearsay. Do the earlier emails come in is given below

Explanation:

1.Mohamed Siddiqui appeals his convictions for fraud and false statements to a federal agency, and obstruction in connection with a federal investigation.   Siddiqui challenges the district court's admission into evidence of e-mail and foreign depositions.

2.On February 18, 1997, Jodi Saltzman, a special agent with the NSF interviewed Siddiqui at Siddiqui's office at the University of South Alabama.   During the interview, Siddiqui signed a statement admitting that he had nominated himself for the Waterman Award, but that he had permission from Yamada and von Gunten to submit forms on their behalf.   Siddiqui also acknowledged in the statement that Westrick had recommended Siddiqui for a different award, the PECASE Award, but that Siddiqui had changed the wording of the letter to apply to the Waterman Award.   Siddiqui was indicted on April 29, 1997.

3.Siddiqui opposed the taking of the depositions on the grounds that the witnesses' personal presence at trial was necessary, and that Indian travel restrictions for its citizens residing abroad prevented him from traveling to Japan and Switzerland.   Specifically, Siddiqui asserted that because of religious persecution in India his travel to Japan or Switzerland related to the criminal action would put his family members still living in India at risk.   The magistrate judge ruled that the government had carried its burden of showing that Yamada and von Gunten would be unavailable to appear at trial, and instructed that Siddiqui's fear of obtaining a travel visa from India because of the threat of persecution of family members should not preclude the taking of the foreign depositions.

4.Yamada's deposition was taken in Japan on March 6, 1998.   At government expense, Siddiqui's counsel attended the deposition and cross-examined the witness, but was not in telephonic contact with Siddiqui during the deposition.   Yamada testified that on February 1, 1997, she received an e-mail stating that if she received a phone call from the NSF to “please tell good words about me.”   Yamada testified that she knew the e-mail was from Siddiqui because the name on the e-mail had Siddiqui's sender address, and it ended with the name “Mo” which Siddiqui had previously told her was his nickname, and which he had used in previous e-mail.

5.Yamada later admitted to Saltzman that she had not given Siddiqui permission to sign, but had made the earlier representation because she thought Siddiqui would go to jail.

6.During cross-examination of Yamada at the deposition, Siddiqui's counsel introduced an e-mail from Yamada to Siddiqui.   This e-mail contained the same e-mail address for Siddiqui as the e-mail received by Yamada and von Gunten apparently from Siddiqui.

7.Von Gunten's video deposition was taken in Switzerland.   At government expense, Siddiqui's counsel attended the deposition and cross-examined von Gunten.   During the deposition, Siddiqui was in communication with his counsel by telephone.   Von Gunten testified at the deposition that he had not submitted a letter of recommendation in favor of Siddiqui for the Waterman Award, and that he had not given Siddiqui permission to submit such a letter in his name.

8 0
3 years ago
g If the rails are originally laid in contact, what is the stress in them on a summer day when their temperature is 31.0
Anettt [7]

A) The amount of space must be left between adjacent rails if they are just to touch on a summer day when their temperature is 31.0 °C is; 0.6048 cm

B) The stress in the rails on a summer day when their temperature is 31.0 °C is; 86.4 × 10⁶ Pa

<h3>Linear Thermal Expansion</h3>

We are given;

Length; L = 14 m

Initial Temperature; T_i = −5 °C

Final Temperature; T_f = 31 °C

The formula for Linear Thermal Expansion is;

ΔL = L_i * α * ΔT

where;

L_i is initial length

α is thermal expansion

ΔL is change in length

ΔT is change in temperature

Now, the thermal expansion of steel from online tables is α = 1.2 × 10⁻⁵ C⁻¹

Thus;

ΔL = 14 * 1.2 × 10⁻⁵  * (31 - (-5))

ΔL = 6.048 × 10⁻³ m = 0.6048 cm

The formula to get the stress is;

σ = Y * α  * ΔT

where;

Y is young's modulus of steel = 20 × 10¹⁰ Pa

α is thermal expansion

ΔT is change in temperature

Thus;

σ = 20 × 10¹⁰ × 1.2 × 10⁻⁵ × (31 - (-5))

σ = 86.4 × 10⁶ Pa

The complete question is;

Steel train rails are laid in 14.0-m long segments placed end to end. The rails are laid on a winter day when their temperature is −5 °C.

(a) How much space must be left between adjacent rails if they are just to touch on a summer day when their temperature is 31.0 °C?

(b) If the rails are originally laid in contact, what is the stress in them on a summer day when their temperature is 31.0 °C?

Read more about Linear Thermal Expansion at; brainly.com/question/6985348

4 0
2 years ago
What impact does modulus elasticity have on the structural behavior of a mechanical design?
devlian [24]

Answer with Explanation:

The modulus of elasticity has an profound effect on the mechanical design of any machine part as explained below:

1) Effect on the stiffness of the member: The ability of any member of a machine to resist any force depends on the stiffness of the member. For a member with large modulus of elasticity the stiffness is more and hence in cases when the member has to resist a direct load the member with more modulus of elasticity resists the force better.

2)Effect on the deflection of the member: The deflection caused by a force in a member is inversely proportional to the modulus of elasticity of the member thus in machine parts in which we need to resist the deflections caused by the load we can use materials with greater modulus of elasticity.

3) Effect to resistance of shear and torque: Modulus of rigidity of a material is found to be larger if the modulus of elasticity of the material is more hence for a material with larger modulus of elasticity  the resistance it offer's to shear forces and the torques is more.

While designing a machine element since the above factors are important to consider thus we conclude that modulus of elasticity has a profound impact on machine design.

8 0
3 years ago
Other questions:
  • A 600-MW steam power plant, which is cooled by a nearby river, has a thermal efficiency of 54 percent. Determine the rate of hea
    9·1 answer
  • Two players find themselves in a legal battle over a patent. The patent is worth 20 for each player, so the winner would receive
    14·1 answer
  • Sophia is designing a new welding shop for the local high school. Where should the compressed gas and fuel cylinders be stored?
    15·1 answer
  • A field sample of an unconfined aquifer is packed in a test cylinder. The length and diameter of the cylinder are 50 cm and 6 cm
    9·1 answer
  • Two kilograms of air within a piston–cylinder assembly executes a Carnot power cycle with maximum and minimum temperatures of 80
    5·2 answers
  • PLEASE ANSWER THIS DIAL CALIPER
    9·1 answer
  • Which one of the following is not an economic want?
    6·1 answer
  • State 3 advantages and 3 disadvantages of unit rate contract​
    10·1 answer
  • Ignition for heavy fuel oil?
    12·2 answers
  • What’s the answer to this I don’t understand
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!