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
It is desired to produce and aligned carbon fiber-epoxy matrix composite having a longitudinal tensile strength of 630 MPa. Calc
ratelena [41]

Answer:

The answer is below

Explanation:

Given that:

Diameter (D) = 0.03 mm = 0.00003 m, length (L) = 2.4 mm = 0.0024 m, longitudinal tensile strength (\sigma_{cd})=630\ MPa = 630*10^6\ Pa, Fracture strength

(\sigma_f)=5100\ MPa=5100*10^6\ Pa,fiber-matrix\ stres(\sigma_m)=17.5\ MPa=17.5*10^6\ Pa,matrix\ strength=\tau_c=17\ MPa=17 *10^6\ Pa

a) The critical length (L_c) is given by:

L_c=\sigma_f*(\frac{D}{2*\tau_c} )=5100*10^6*\frac{0.00003}{2*17*10^6}=0.0045\ m=4.5\ mm

The critical length (4.5 mm) is greater than the given length, hence th composite can be produced.

b) The volume fraction (Vf) is gotten from the formula:

\sigma_{cd}=\frac{L*\tau_c}{D}*V_f+\sigma_m(1-V_f)\\\\V_f=\frac{\sigma_{cd}-\sigma_{m}}{\frac{L*\tau_c}{D}-\sigma_{m}}  \\\\Substituting:\\\\V_f=\frac{630*10^6-17.5*10^6}{\frac{0.0024*17*10^6}{0.00003} -17.5*10^6} \\\\V_f=0.456

6 0
3 years ago
what i the maximum flow rate of glycerine at 20C in a 10cm diameter pipe that can be assumed to remain laminar
ELEN [110]

Answer: tube flow

Explanation:

7 0
3 years ago
Calculate the amount of current flowing through a 75-watt light bulb that is connected to a 120-volt circuit in your home.
vodomira [7]

Answer:

I = 0.625 A

Explanation:

Given that,

Power of the light bulb, P = 75 W

Voltage of the circuit, V = 120 V

We need to find the current flowing through it. We know that, Power is given by :

P=V\times I

I is the electric current

I=\dfrac{P}{V}\\\\I=\dfrac{75\ W}{120\ V}\\\\I=0.625\ A

So, the current is 0.625 A.

5 0
3 years ago
Based on experimental observations, the acceleration of a particle is defined by the relationa = -( 0.1 + sin(x/b) ),where a and
yKpoI14uk [10]

Answer:

a) v = +/- 0.323 m/s

b) x = -0.080134 m

c) v = +/- 1.004 m/s

Explanation:

Given:

                             a = - (0.1 + sin(x/b))

b = 0.8

v = 1 m/s @ x = 0

Find:

(a) the velocity of the particle when x = -1 m

(b) the position where the velocity is maximum

(c) the maximum velocity.

Solution:

- We will compute the velocity by integrating a by dt.

                           a = v*dv / dx =  - (0.1 + sin(x/0.8))

- Separate variables:

                           v*dv = - (0.1 + sin(x/0.8)) . dx

-Integrate from v = 1 m/s @ x = 0:

                          0.5(v^2) = - (0.1x - 0.8cos(x/0.8)) - 0.8 + 0.5

                          0.5v^2 =  0.8cos(x/0.8) - 0.1x - 0.3

- Evaluate @ x = -1

                          0.5v^2 = 0.8 cos(-1/0.8) + 0.1 -0.3

                          v = sqrt (0.104516)

                          v = +/- 0.323 m/s

- v = v_max when a = 0:

                           -0.1 = sin(x/0.8)

                             x = -0.8*0.1002

                             x = -0.080134 m

- Hence,

                            v^2 = 1.6 cos(-0.080134/0.8) -0.6 -0.2*-0.080134

                            v = sqrt (0.504)

                            v = +/- 1.004 m/s

4 0
3 years ago
Please help me it’s for science I only have a few minutes
7nadin3 [17]

Answer:

Rocks

Explanation:

I am not sure tho bc they are made out of coal and I think coal is a kind of rock

3 0
2 years ago
Read 2 more answers
Other questions:
  • Use the orange points (square symbol) to plot the initial short-run industry supply curve when there are 20 firms in the market.
    5·1 answer
  • Single point cutting tool removes material from a rotating work piece to generate a cylinder is called • Facing Tuming • Both 1
    6·1 answer
  • After a 65 newton weight has fallen freely from rest a vertical distance of 5.3 meters, the kinetic energy of the weight is
    12·1 answer
  • Barry wants to convert mechanical energy into electric energy. What can he use?
    5·2 answers
  • Please read and answer each question carefully.
    9·1 answer
  • Give six reasons why farmers cultivate on small land​
    5·1 answer
  • How large a force is required to accelerate a 1300 kg car from rest to a speed of 20 m/s in a distance of 80 m?
    15·2 answers
  • When we say that communication is
    13·1 answer
  • What are the main microsoft ware packages widely used today​
    6·2 answers
  • Ferroconcrete is reinforced concrete that combines concrete and ________. A. Lead c. Copper b. Iron d. Aluminum.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!