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
Firefighters are holding a nozzle at the end of a hose while trying to extinguish a fire. The nozzle exit diameter is 8 cm, and
ivanzaharov [21]

Question

Determine the average water exit velocity

Answer:

53.05 m/s

Explanation:

Given information

Volume flow rate, Q=16 m^{3}/min

Diameter d= 8cm= 0.08 m

Assumptions

  • The flow is jet flow hence momentum-flux correction factor is unity
  • Gravitational force is not considered
  • The flow is steady, frictionless and incompressible
  • Water is discharged to the atmosphere hence pressure is ignored

We know that Q=AV and making v the subject then

V=\frac {Q}{A} where V is the exit velocity and A is area

Area, A=\frac {\pi d^{2}{4} where d is the diameter

By substitution

V=\frac {16\times 4}{\pi 0.08^{2}}=3183.098862 m/min

To convert v to m/s from m/s, we simply divide it by 60 hence

V=\frac {3183.098862  m/min}{60 s}=53.0516477 m/s\approx 53.05 m/s

3 0
3 years ago
A masonry facade consisting of 3,800 square feet is to be constructed for a building. The total cost per worker hour is estimate
lana66690 [7]

Answer:

Days: 6.9444 days

Production rate: 547.2035 ft²/s

Explanation:

the solution is attached in the Word file

Download docx
6 0
3 years ago
Water flows through a nozzle at the end of a fire hose. If the nozzle exit velocity must be 20 m/s and the exit diameter is 40 m
lara31 [8.8K]

Answer:

minimum flow rate provided by pump is 0.02513 m^3/s

Explanation:

Given data:

Exit velocity of nozzle = 20m/s

Exit diameter = 40 mm

We know that flow rate Q is given as

Q = A \times V

where A is Area

A =\frac{\pi}{4} \times (40\times 10^{-3})^2 = 1.256\times 10^{-3} m^2

Q = 1.256\times 10^{-3} \times 20 = 0.02513 m^3/s

minimum flow rate provided by pump is 0.02513 m^3/s

5 0
3 years ago
A distribution center is used in which of the following applications?
FrozenT [24]

both b and c are the right

5 0
3 years ago
I have to find the critical points of this function of two variables <img src="https://tex.z-dn.net/?f=%5C%5Cf%28x%2Cy%29%3Dx%5E
liraira [26]

Answer:

no i dont think there is

Explanation:

because theres not

4 0
3 years ago
Other questions:
  • This problem demonstrates aliasing. Generate a 512-point waveform consisting of 2 sinusoids at 200 and 400-Hz. Assume a sampling
    8·1 answer
  • How do scientists and engineers use math to help them?
    14·1 answer
  • Early American rockets used an RC circuit to set the time for the rocket to begin re-entry after launch (true story). Assume the
    5·1 answer
  • List one advantage and one disadvantage of the use of the commutator?
    8·1 answer
  • How do I calculate the gear ratio​
    6·1 answer
  • Consider laminar, fully developed flow in a channel of constant surface temperature Ts. For a given mass flow rate and channel l
    15·1 answer
  • Summarize three attributes that are important for an engineer to possess.
    13·1 answer
  • Help me with this for brainiest:)
    8·1 answer
  • What is the process pf distributing and selling clean fuel?​
    6·1 answer
  • A fully charged new battery will have a low conductance reading.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!