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
1. ELECTRICAL SHOCK
lions [1.4K]
Here’s some of them
6. J
7. I
10. O
13. F
14. E
15. N
3 0
3 years ago
A circular specimen of MgO is loaded in three-point bending. Calculate the minimum possible radius of the specimen without fract
Hitman42 [59]

Answer:

radius = 9.1 × 10^{-3} m

Explanation:

given data

applied load = 5560 N

flexural strength = 105 MPa

separation between the support =  45 mm

solution

we apply here minimum radius formula that is

radius = \sqrt[3]{\frac{FL}{\sigma \pi}}      .................1

here F is applied load and  is length

put here value and we get

radius =  \sqrt[3]{\frac{5560\times 45\times 10^{-3}}{105 \times 10^6 \pi}}  

solve it we get

radius = 9.1 × 10^{-3} m

8 0
3 years ago
Velocity components in an incompressible flow are: v = 3xy + x^2 y: w = 0. Determine the velocity component in the x-direction.
cupoosta [38]

Answer:

Velocity component in x-direction u=-\frac{3}{2}x^2-\frac{1}{3}x^3.

Explanation:

   v=3xy+x^{2}y

We know that for incompressible flow

   \frac{\partial u}{\partial x}+\frac{\partial v}{\partial y}=0

\frac{\partial v}{\partial y}=3x+x^{2}

So   \frac{\partial u}{\partial x}+3x+x^{2}=0

\frac{\partial u}{\partial x}= -3x-x^{2}

By integrate with respect to x,we will find

u=-\frac{3}{2}x^2-\frac{1}{3}x^3+C

So the velocity component in x-direction u=-\frac{3}{2}x^2-\frac{1}{3}x^3.

3 0
3 years ago
A utility generates electricity with a 36% efficient coal-fired power plant emitting the legal limit of 0.6 lb of SO2 per millio
Mama L [17]

Answer:

a) 570 kWh of electricity will be saved

b) the amount of  SO₂ not be emitted or heat of electricity saved is 0.00162 ton/CLF

c) $1.296 can be earned by selling the SO₂ saved by a single CFL

Explanation:

Given the data in the question;

a) How many kilowatt-hours of electricity would be saved?

first, we determine the total power consumption by the incandescent lamp

P_{incandescent} = 75 w × 10,000-hr = 750000 wh = 750 kWh

next, we also find  the total power consumption by the fluorescent lamp

P_{fluorescent} = 18 × 10000 = 180000 = 180 kWh

So the value of power saved will be;

P_{saved} = P_{incandescent}  - P_{fluorescent}

P_{saved} = 750 - 180

P_{saved}  = 570 kWh

Therefore, 570 kWh of electricity will be saved.

now lets find the heat of electricity saved in Bituminous

heat saved = energy saved per CLF / efficiency of plant

given that; the utility has 36% efficiency

we substitute

heat saved =  570 kWh/CLF / 36%

we know that; 1 kilowatt (kWh) = 3,412 btu per hour (btu/h)

so

heat saved =  570 kWh/CLF / 0.36 × (3412 Btu / kW-hr (

heat saved = 5.4 × 10⁶ Btu/CLF

i.e eat of electricity saved per CLF is 5.4 × 10⁶

b) How many 2,000-lb tons of SO₂ would not be emitted

2000 lb/tons = 5.4 × 10⁶ Btu/CLF

0.6 lb SO₂ / million Btu = x

so

x = [( 5.4 × 10⁶ Btu/CLF ) × ( 0.6 lb SO₂ /  million Btu )] / 2000 lb/tons

x = [( 5.4 × 10⁶ Btu/CLF ) × ( 0.6 lb SO₂ )] / [ ( 10⁶) × ( 2000 lb/ton) ]

x = 3.24 × 10⁶ / 2 × 10⁹

x = 0.00162 ton/CLF

Therefore, the amount of  SO₂ not be emitted or heat of electricity saved is 0.00162 ton/CLF

c)  If the utility can sell its rights to emit SO2 at $800 per ton, how much money could the utility earn by selling the SO2 saved by a single CFL?

Amount = ( SO₂ saved per CLF ) × ( rate per CFL )

we substitute

Amount = 0.00162 ton/CLF × $800

= $1.296

Therefore; $1.296 can be earned by selling the SO₂ saved by a single CFL.

3 0
3 years ago
public interface Frac { /** @return the denominator of this fraction */ int getDenom(); /** @return the numerator of this fracti
True [87]

Answer:

The Full details of the answer is attached.

7 0
3 years ago
Other questions:
  • Explain the use of the Kanban system in a production line?
    7·1 answer
  • Vending machine controller (adapted from Katz, "Contemporary Logic Design") Design and implement a finite state machine that con
    10·1 answer
  • Both carpenters and building inspectors have been associated with the personality characteristics identified as realistic, conve
    12·1 answer
  • For the system in problem 4, suppose a main memory access requires 30ns, the page fault rate is .01%, it costs 12ms to access a
    14·1 answer
  • Q-) please give me a reference about Tack coat? Pleae i need it please??!!
    14·1 answer
  • What is the scope of hazard review in a worksite analysis
    7·1 answer
  • Question
    8·1 answer
  • Puan puan puan vericim
    5·2 answers
  • The current at resonance in a series L-C-R circuit is 0.2mA. If the applied voltage is 250mV at a frequency of 100 kHz and the c
    9·1 answer
  • When starting up a dual fuel system, the temperature rise method for determining airflow cannot be used with the compressor cycl
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!