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
timofeeve [1]
3 years ago
9

In this milestone we will create a Course class to represent a course and display its information on the screen. We will create

two global functions that will validate the courses in a schedule file and store it in an array of Course objects, and display information from an array of Course objects.
Engineering
1 answer:
son4ous [18]3 years ago
4 0

Answer:

Code is given below:

Explanation:

Please enter the file name containing the list of classes: sched.txt

Schedule file loaded. Displaying contents ...

Course name: CPSC 131

Location: EC 109

Weekly schedule: MW

Start time: 16:00

End time: 17:15

Course name: CPSC 481

Location: CS 408

Weekly schedule: MW

Start time: 16:00

End time: 17:15

Course name: CPSC 362

Location: CS 101

Weekly schedule: MW

Start time: 8:00

End time: 9:50

Thank you for using Tuffy Scheduler.

Start time happens after end time

cources.txt

CPSC 131,EC 109,MW,16:00,17:15

CPSC 481,CS 408,MW,16:00,17:15

CPSC 362,CS 101,MW,8:00,9:50

#include <iostream>

#include <fstream>

#include <sstream>

#include<vector>

using namespace std;

class Course {

private:

  std::string course_name_;

  std::string location_;

  std::string weekly_schedule_;

  int start_time_;

  int end_time_;

public:

  const std::string& getCourseName() const {

      return course_name_;

  }

  void setCourseName(const std::string& courseName) {

      course_name_ = courseName;

  }

  const std::string getEndTime() const {

      std::string st = to_string(end_time_);

      std::string st2 = st.substr(st.length() - 2);

      //cout << st2 << '\n';

      size_t found = st.find(st2);

      std::string st1 = st.substr(0, found);

      std::string st3 = st1 + ":" + st2;

      return st3;

  }

  void setEndTime(int endTime) {

      end_time_ = endTime;

  }

  const std::string& getLocation() const {

      return location_;

  }

  void setLocation(const std::string& location) {

      location_ = location;

  }

  const std::string getStartTime() const {

      std::string st = to_string(start_time_);

      std::string st2 = st.substr(st.length() - 2);

      //cout << st2 << '\n';

      size_t found = st.find(st2);

      std::string st1 = st.substr(0, found);

      std::string st3 = st1 + ":" + st2;

      return st3;

  }

  void setStartTime(int startTime) {

      start_time_ = startTime;

  }

  const std::string& getWeeklySchedule() const {

      return weekly_schedule_;

  }

  void setWeeklySchedule(const std::string& weeklySchedule) {

      weekly_schedule_ = weeklySchedule;

  }

  void display() {

      cout << "Course name: " << course_name_ << endl;

      cout << "Location: " << location_ << endl;

      cout << "Weekly schedule: " << weekly_schedule_ << endl;

      cout << "Start time:" << getStartTime() << endl;

      cout << "End time:" << getEndTime() << endl;

  }

};

bool load_schedule(std::string fileName, Course (&courses)[100], int& curSize);

int main() {

  cout << "Welcome to Tuffy Scheduler!" << endl;

  cout << "Please enter the file name containing the list of classes:"

          << endl;

  std::string fileName;

  Course courses[100];

  int curSize = 0;

  cin >> fileName; // provide complete path ex D:\\Chegg\\CheggCpp\\src\\cources.txt

  if (load_schedule(fileName, courses, curSize)) {

      cout << "Schedule file loaded. Displaying contents ..." << endl<<endl;

      int i;

      //cout << curSize << '\n';

      for (i = 0; i < curSize; i++) {

          courses[i].display();

          cout << endl;

      }

      cout << "Thank you for using Tuffy Scheduler."<< endl;

      cout << "Start time happens after end time"<< endl;

  } else {

      cout << "Invalid file" << endl;

  }

  return 0;

}

bool load_schedule(std::string fileName, Course (&courses)[100], int& curSize) {

  ifstream myfile(fileName);

  string line;

  //cout << fileName << '\n';

  if (myfile.is_open()) {

      while (getline(myfile, line)) {

          stringstream ss(line);

          vector<string> v;

          while (ss.good()) {

              string substr;

              getline(ss, substr, ',');

              v.push_back(substr);

          }

          Course c;

          c.setCourseName(v[0]);

          c.setLocation(v[1]);

          c.setWeeklySchedule(v[2]);

          if (v[2] != "MW") {

              cout << "Error: Invalid weekly schedule symbol " << v[2]

                      << '\n';

              return false;

          }

          //set start time

          string startTime = v[3];

          size_t found = startTime.find(":");

          startTime.erase(found, 1);

          //cout << startTime << '\n';

          stringstream st(startTime);

          int startTimeInt = 0;

          st >> startTimeInt;

          c.setStartTime(startTimeInt);

          //set end time

          string endTime = v[4];

          found = endTime.find(":");

          endTime.erase(found, 1);

          // cout << endTime << '\n';

          stringstream st1(endTime);

          int endTimeInt = 0;

          st1 >> endTimeInt;

          c.setEndTime(endTimeInt);

          if (startTimeInt > endTimeInt) {

              cout << "Error: The start time " << startTimeInt

                      << "should happen before the end time " << endTimeInt

                      << '\n';

              return false;

          }

          courses[curSize] = c;

          curSize++;

          //cout << curSize << '\n';

      }

      myfile.close();

  }

  return true;

}

You might be interested in
simple Brayton cycle using air as the working fluid has a pressure ratio of 10. The minimum and maximum temperatures in the cycl
Irina18 [472]

Answer:

a) 764.45K

b) 210.48 kJ/kg

c) 30.14%

Explanation:

pressure ratio = 10

minimum temperature = 295 k

maximum temperature = 1240 k

isentropic efficiency for compressor = 83%

Isentropic efficiency for turbine = 87%

<u>a) Air temperature at turbine exit </u>

we can achieve this by interpolating for enthalpy

h4 = 783.05 kJ/kg ( calculated in the background ) at state 4 using Table A-17  for  Ideal gas properties of air

T4 ( temperature at Turbine exit ) = 760 + ( 780 - 760 ) (\frac{783.05-778.18}{800.13-778.18} ) = 764.45K

<u>b) The net work output </u>

first we determine the actual work input to compressor

Wc = h2 - h1  ( calculated values )

     = 626.57 - 295.17 =  331.4 kJ/kg

next determine the actual work done by Turbine

Wt = h3 - h4  ( calculated values )

     = 1324.93 - 783.05 = 541.88 kJ/kg

finally determine the network output of the cycle

Wnet = Wt - Wc

         = 541.88 - 331.4  = 210.48 kJ/kg

<u>c) determine thermal efficiency </u>

лth = Wnet / qin  ------ ( 1 )

where ; qin = h3 - h2

<em>equation 1 becomes </em>

лth = Wnet / ( h3 - h2 )

      = 210.48 / ( 1324.93 - 626.57 )

      = 0.3014  =  30.14%

6 0
3 years ago
An alloy is evaluated for potential creep deformation in a short-term laboratory experiment. The creep rate (ϵ˙) is found to be
cupoosta [38]

Answer:

Activation energy for creep in this temperature range is Q = 252.2 kJ/mol

Explanation:

To calculate the creep rate at a particular temperature

creep rate, \zeta_{\theta} = C \exp(\frac{-Q}{R \theta} )

Creep rate at 800⁰C, \zeta_{800} = C \exp(\frac{-Q}{R (800+273)} )

\zeta_{800} = C \exp(\frac{-Q}{1073R} )\\\zeta_{800} = 1 \% per hour =0.01\\

0.01 = C \exp(\frac{-Q}{1073R} ).........................(1)

Creep rate at 700⁰C

\zeta_{700} = C \exp(\frac{-Q}{R (700+273)} )

\zeta_{800} = C \exp(\frac{-Q}{973R} )\\\zeta_{800} = 5.5 * 10^{-2}  \% per hour =5.5 * 10^{-4}

5.5 * 10^{-4}  = C \exp(\frac{-Q}{1073R} ).................(2)

Divide equation (1) by equation (2)

\frac{0.01}{5.5 * 10^{-4} } = \exp[\frac{-Q}{1073R} -\frac{-Q}{973R} ]\\18.182= \exp[\frac{-Q}{1073R} +\frac{Q}{973R} ]\\R = 8.314\\18.182= \exp[\frac{-Q}{1073*8.314} +\frac{Q}{973*8.314} ]\\18.182= \exp[0.0000115 Q]\\

Take the natural log of both sides

ln 18.182= 0.0000115Q\\2.9004 = 0.0000115Q\\Q = 2.9004/0.0000115\\Q = 252211.49 J/mol\\Q = 252.2 kJ/mol

3 0
2 years ago
Explain the difference between thermoplastics and thermosets giving structure property correlation.
Misha Larkins [42]

Answer:

Explanation:

Thermosetting polymers are infusible and insoluble polymers. The reason for such behavior is that the chains of these materials form a three-dimensional spatial network, intertwining with strong equivalent bonds. The structure thus formed is a conglomerate of interwoven chains giving the appearance and functioning as a macromolecule, which as the temperature rises, simply the chains are more compacted, making the polymer more resistant to the point where it degrades.

Macromolecules are molecules that have a high molecular mass, formed by a large number of atoms. Generally they can be described as the repetition of one or a few minimum units or monomers, forming the polymers. In contrast, a thermoplastic is a material that at relatively high temperatures, becomes deformable or flexible, melts when heated and hardens in a glass transition state when it cools sufficiently. Most thermoplastics are high molecular weight polymers, which have associated chains through weak Van der Waals forces (polyethylene); strong dipole-dipole and hydrogen bond interactions, or even stacked aromatic rings (polystyrene). Thermoplastic polymers differ from thermosetting polymers or thermofixes in that after heating and molding they can overheat and form other objects.

Thermosetting plastics have some advantageous properties over thermoplastics. For example, better resistance to impact, solvents, gas permeation and extreme temperatures. Among the disadvantages are, generally, the difficulty of processing, the need for curing, the brittle nature of the material (fragile) and the lack of reinforcement when subjected to tension. But even so in many ways it surpasses the thermoplastic.

The physical properties of thermoplastics gradually change if they are melted and molded several times (thermal history), these properties are generally diminished by weakening the bonds. The most commonly used are polyethylene (PE), polypropylene (PP), polybutylene (PB), polystyrene (PS), polymethylmethacrylate (PMMA), polyvinylchloride (PVC), ethylene polyterephthalate (PET), Teflon (or polytetrafluoroethylene, PTFE) and nylon (a type of polyamide).

They differ from thermosets or thermofixes (bakelite, vulcanized rubber) in that the latter do not melt when raised at high temperatures, but burn, making it impossible to reshape them.

Many of the known thermoplastics can be the result of the sum of several polymers, such as vinyl, which is a mixture of polyethylene and polypropylene.

When they are cooled, starting from the liquid state and depending on the temperatures to which they are exposed during the solidification process (increase or decrease), solid crystalline or non-crystalline structures may be formed.

This type of polymer is characterized by its structure. It is formed by hydrocarbon chains, like most polymers, and specifically we find linear or branched chains

4 0
3 years ago
In the circuit given below, R1 = 17 kΩ, R2 = 74 kΩ, and R3 = 5 MΩ. Calculate the gain 1formula58.mml when the switch is in posit
Elenna [48]

Answer:a

a) Vo/Vi = - 3.4

b) Vo/Vi = - 14.8

c) Vo/Vi = - 1000

Explanation:

a)

R1 = 17kΩ

for ideal op-amp

Va≈Vb=0 so Va=0

(Va - Vi)/5kΩ + (Va -Vo)/17kΩ = 0

sin we know Va≈Vb=0

so

-Vi/5kΩ + -Vo/17kΩ = 0

Vo/Vi = - 17k/5k

Vo/Vi = -3.4

║Vo/Vi ║ = 3.4    ( negative sign phase inversion)

b)

R2 = 74kΩ

for ideal op-amp

Va≈Vb=0 so Va=0

so

(Va-Vi)/5kΩ + (Va-Vo)74kΩ = 0

-Vi/5kΩ + -Vo/74kΩ = 0

Vo/Vi = - 74kΩ/5kΩ

Vo/Vi = - 14.8

║Vo/Vi ║ = 14.8  ( negative sign phase inversion)

c)

Also for ideal op-amp

Va≈Vb=0 so Va=0

Now for position 3 we apply nodal analysis we got at position 1

(Va - Vi)/5kΩ + (Va - Vo)/5000kΩ = 0           ( 5MΩ = 5000kΩ )

so

-Vi/5kΩ + -Vo/5000kΩ = 0

Vo/Vi = - 5000kΩ/5kΩ

Vo/Vi = - 1000

║Vo/Vi ║ = 1000  ( negative sign phase inversion)

3 0
3 years ago
Which of the following is the class of ingredient which is the base for most baked items?
Ierofanga [76]

Answer:flour

Explanation:

3 0
2 years ago
Other questions:
  • How was math used to determine new origami crease plans?
    10·1 answer
  • Are spheroidized steels considered as composite? If so, what is the dispersed phase a)- No b)- Yes, Chromium Carbides c)- Yes, I
    12·1 answer
  • Compute the number of kilo- grams of hydrogen that pass per hour through a 6-mm-thick sheet of palladium having an area of 0.25
    12·1 answer
  • A geothermal heat pump absorbs 15 KJ/s of heat from the Earth 15 m below a house. This heat pump uses a 7.45 kJ/s compressor.
    14·2 answers
  • In homes today, what is behind the reason for flashover fires occurring much more rapidly than in the past generations?
    8·1 answer
  • Pointttttttttttttssssssssssss
    12·1 answer
  • Policeman says, "Son, you can't stay here"
    9·1 answer
  • Who made the frist ever car
    13·2 answers
  • The three construction crafts that require a MINIMUM of a 4-year college degree are
    11·1 answer
  • Question is written in following attached screenshot.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!