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
Consider a W21x93. Determine the moment capacity of the beam. Assume the compression flange is not laterally braced and that the
OLga [1]

Answer:

The answer is "828.75"

Explanation:

Please find the correct question:

For W21x93 BEAM,

Z_x = 221.00 in^3 \\\\\to \frac{b_t}{2t_f} =4.53\\\\\to \frac{h}{t_w}=32.3

For A992 STREL,

F_y= 50\  ks

Check for complete section:

\to \frac{b_t}{2t_f} =4.53 < \frac{65}{\sqrt{f_y = 9.19}}\\\\\to \frac{h}{t_w} =32.3 < \frac{640}{\sqrt{f_y = 90.5}}

Design the strength of beam =\phi_b Z_x F_y\\\\

                                                =0.9 \times 221 \times 50\\\\=9945 \ in \ \ kips\\\\=\frac{9945}{12}\\\\= 828.75 \ft \ kips \\

8 0
3 years ago
U 4. Find 2 bridges in the US and answer the following:
Zarrin [17]

Answer:

Im guessing this is for CEA for PLTW, if so look up the exact assignment number and look at online examples of the exact same assignment.

Explanation:

6 0
3 years ago
A 03-series cylindrical roller bearing with inner ring rotating is required for an application in which the life requirement is
-BARSIC- [3]

Answer:

\mathbf{C_{10} = 137.611 \ kN}

Explanation:

From the information given:

Life requirement = 40 kh = 40 40 \times 10^{3} \ h

Speed (N) = 520 rev/min

Reliability goal (R_D) = 0.9

Radial load (F_D) = 2600 lbf

To find C10 value by using the formula:

C_{10}=F_D\times \pmatrix \dfrac{x_D}{x_o +(\theta-x_o) \bigg(In(\dfrac{1}{R_o}) \bigg)^{\dfrac{1}{b}}} \end {pmatrix} ^{^{^{\dfrac{1}{a}}

where;

x_D = \text{bearing life in million revolution} \\  \\ x_D = \dfrac{60 \times L_h \times N}{10^6} \\ \\ x_D = \dfrac{60 \times 40 \times 10^3 \times 520}{10^6}\\ \\ x_D = 1248 \text{ million revolutions}

\text{The cyclindrical roller bearing (a)}= \dfrac{10}{3}

The Weibull parameters include:

x_o = 0.02

(\theta - x_o) = 4.439

b= 1.483

∴

Using the above formula:

C_{10}=1.4\times 2600 \times \pmatrix \dfrac{1248}{0.02+(4.439) \bigg(In(\dfrac{1}{0.9}) \bigg)^{\dfrac{1}{1.483}}} \end {pmatrix} ^{^{^{\dfrac{1}{\dfrac{10}{3}}}

C_{10}=3640 \times \pmatrix \dfrac{1248}{0.02+(4.439) \bigg(In(\dfrac{1}{0.9}) \bigg)^{\dfrac{1}{1.483}}} \end {pmatrix} ^{^{^{\dfrac{3}{10}}

C_{10} = 3640 \times \bigg[\dfrac{1248}{0.9933481582}\bigg]^{\dfrac{3}{10}}

C_{10} = 30962.449 \ lbf

Recall that:

1 kN = 225 lbf

∴

C_{10} = \dfrac{30962.449}{225}

\mathbf{C_{10} = 137.611 \ kN}

7 0
3 years ago
**Please Help. ASAP**
natima [27]

Answer:

The answer is below

Explanation:

1)

\frac{v-u}{a} =t\\\\Making \ v\ the \ subject\ of\ formula:\\\\First \ cross-multiply:\\\\v-u=at\\\\add\ u\ to \ both\ sides:\\\\v-u+u=at+u\\\\v=u+at

2)

\frac{y-x^2}{x}=3z\\ \\Making\ y\ the\ subject\ of\ formula:\\\\First \ cross \ multiply:\\\\y-x^2=3xz\\\\y=3xz+x^2\\\\y=x(x+3z)

3)

x+xy=y\\\\Making\ x\ the\ subject\ of\ formula:\\\\x(1+y)=y\\\\Divide\ through\ by\ 1+y\\\\\frac{x(1+y)}{1+y} =\frac{y}{1+y} \\\\x=\frac{y}{1+y}

4)

x+y=xy\\\\Making\ x\ the\ subject\ of\ formula:\\\\Subtract\ x\ from \ both\ sides:\\\\x+y-x=xy-x\\\\y=xy-x\\\\y=x(y-1)\\\\Divide\ through\ by \ y-1\\\\\frac{y}{y-1} =\frac{x(y-1)}{y-1}\\ \\x=\frac{y}{y-1}

5)

x=y+xy\\\\Making\ x\ the\ subject\ of\ formula:\\\\Subtract\ xy\ from \ both\ sides:\\\\x-xy=y+xy-xy\\\\x-xy=y\\\\x(1-y)=y\\\\Divide\ through\ by \ 1-y\\\\\frac{x(1-y)}{1-y} =\frac{y}{1-y}\\ \\x=\frac{y}{1-y}

6)

E=\frac{1}{2}mv^2-\frac{1}{2}mu^2\\  \\Making\ u\ the\ subject \ of\ formula:\\\\Multiply \ through\ by \ 2\\\\2E=mv^2-mu^2\\\\mu^2=mv^2-2E\\\\Divide\ through\ by\ m:\\\\u^2=\frac{mv^2-2E}{m}\\ \\Take\ square\ root\ of \ both\ sides:\\\\u=\sqrt{\frac{mv^2-2E}{m}}

7)

\frac{x^2}{a^2}-\frac{y^2}{b^2}=1\\  \\Making\ y\ the\ subject \ of\ formula:\\\\\frac{x^2}{a^2}-1=\frac{y^2}{b^2}\\\\Multiply\ through\ by\ b^2\\\\b^2(\frac{x^2}{a^2} -1)=y^2\\\\Take\ square\ root\ of\ both\ sides:\\\\y=\sqrt{b^2(\frac{x^2}{a^2} -1)}

8)

ay^2=x^3\\\\Make\ y\ the\ subject\ of\ formula:\\\\Divide\ through\ by\ a:\\\\y^2=\frac{x^3}{a}\\ \\Take\ square\ root\ of\ both\ sides:\\\\y=\sqrt{\frac{x^3}{a}} \\

4 0
3 years ago
Integer to Float Conversion All labs must be done during lab time. Each labs worth 10 points The lab can be hand in next day wit
andrew-mc [135]

Answer:

Code explained below

Explanation:

.data

msg1: .asciiz "Please input a temperature in celsius: "

msg2: .asciiz "The temperature in Fahrenheit is: => "

num: .float 0.0

.text

main:

#print the msg1

li $v0, 4

la $a0, msg1

syscall

#read the float value from user

li $v0,6 #read float syscall value is $v0

syscall #read value stored in $f0

#formula for celsius to fahrenheit is

#(temperature(C)* 9/5)+32

#li.s means load immediate float

#copy value 9.0 to $f2

li.s $f2,9.0  

#copy value 5.0 to $f3

li.s $f3,5.0

# following instructions performs: 9/5

#div.s - division of two float numbers

#divide $f2 and f3.Result will stores in $f1

div.s $f1,$f2,$f3

#following instruction performs: temperature(C) * (9/5)

#multiple $f1 and $f0.Result stored in $f1

mul.s $f1,$f1,$f0

#copy value 32 to $f4

li.s $f4,32.0

#following instruction performs: (temperature(C) * (9/5))+32

#add $f1 and $f4.Result stores in $f1

add.s $f1,$f1,$f4

#store float from $f1 to num

s.s $f1,num

#print the msg2

li $v0, 4 #print string syscall value is 4

la $a0, msg2 #copy address of msg2 to $a0

#print the float

syscall

li $v0,2 #print float syscall value is 2

l.s $f12,num #load value in num to $f12

syscall

#terminate the program

li $v0, 10 #terminate the program syscall value is 10

syscall

4 0
3 years ago
Other questions:
  • You are a designer of a new processor. You have to choose between two possible implementations (called M1 and M2) of the same ar
    5·1 answer
  • One kilogram of air, initially at 5 bar, 350 K, and 3 kg of carbon dioxide (CO2), initially at 2 bar, 450 K, are confined to opp
    14·1 answer
  • Calculate and plot the radial and circumferential stress distribution in the left ventricle at the end of systole (p 5 80 mmHg;
    13·1 answer
  • Fluorescent troffers are a type of _ lighting fixture
    6·1 answer
  • Q#3:(A)Supose we extend the circular flow mode to add imports and export copy the circular flow digram onto a sheet paper and th
    15·1 answer
  • YO CUTIE! HELP MEEEEEE! Hazardous waste is a category that includes all of the following EXCEPT
    13·2 answers
  • How do guest room hotel smoke alarms work and differ then regular home versions?
    10·2 answers
  • Which of the following is described as a way engineers can test and investigate how things should be under certain circumstances
    8·1 answer
  • Explain crystallographic defects.
    11·1 answer
  • How can you contribute to achieved the mission of NSTP during pandemic in your society?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!