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
Discuss the organizational system that you believe would be the most effective for the safety officer in a medium-sized (100-200
marin [14]

Answer:

A safety manager is a person who designs and maintains the safety elements at workplace. A balance should be required for production and the job in providing work environment. As a safety officer in a medium sized manufacturing facility the following organizational system can be designed and maintained:

  • Maintaining a workplace as per the guidelines by Occupational safety and health association. The rules and regulation should be such that maintains the manufacturing facilities.  
  • For warning to workers proper labelling, floor mapping, signs, posters should be used.  
  • Procurement and usage of safe tools.  
  • A guideline that describes safety standard and precautionary measures should be available to the workers. They should be aware about all the steps that needs to be taken in crisis.  
  • Ensuring that the workers have enough training safety and health or accident prevention.  
  • Identify and eliminate the hazardous elements from the workplace.  
  • A strict action should be taken against the worker in case of violation of rules and not adhering with guidelines.

3 0
3 years ago
You should use the pass technique a fire extinguisher
PilotLPTM [1.2K]

Answer:

Yes

Explanation:

8 0
3 years ago
The temperature of a system rises by 10 °C during a heating process. Express the rise in temperature of K, R, and °F.
Lorico [155]

Explanation:

Given T = 10 °C

The conversion of T( °C) to T(K) is shown below:

T(K) = T( °C) + 273.15  

So,  

T = (10 + 273.15) K = 283.15 K

<u>T = 283.15 K </u>

The conversion of T( °C) to T(F) is shown below:

T (°F) = (T (°C) × 9/5) + 32  

So,

T (°F) = (10 × 9/5) + 32 = 50 °F

<u>T = 50 °F</u>

The conversion of T( °C) to T(R) is shown below:

T (R) = (T (°C) × 9/5) + 491.67

So,

T (R) = (10 × 9/5) + 491.67 = 509.67 R

<u>T = 509.67 R</u>

6 0
3 years ago
Consider the velocity boundary layer profile for flow over u flat plate to be of the form u = C_1 + C_2 y. Applying appropriate
ra1l [238]

Answer:

The  result in terms of the local Reynolds number ⇒ Re = [μ_∞ · x] / v

Explanation:

See below my full workings so you can compare the results with those obtained from the exact solution.

4 0
3 years ago
All air-conditioning units must be grounded electrically to
Tpy6a [65]

Answer:

Prevent electrical shock

Grounding is a non current carrying conductor mainly used to guard against hazards due to leakage in electric circuits

Explanation:

The grounding refers to the connection of an electrical equipment exposed metallic parts to the ground to serve as a source of current flow in the event of an insulation failure will cause the fuses to trip thereby isolating or removing electric power from the device

Grounding also prevents the accumulation of static electricity which can be a source of fire in inflammable areas.

8 0
3 years ago
Other questions:
  • What are the challenges posed by strategic information systems, and how should they be addressed?
    10·1 answer
  • Cng containers need to be inspected
    7·1 answer
  • There are three options for heating a particular house: a. Gas: $1.33/therm where 1 therm=105,500 kJ b. Electric Resistance: $0.
    9·1 answer
  • I need this asap thank you :) plzzzzz When the spring on a mousetrap car is fully unwound, the force acting on the car is _____.
    11·1 answer
  • WHICH TASK BEST FITS THE ROLE OF A DESIGN ENGINEER ?
    7·1 answer
  • If a tapered roller bearing is adjusted to loose, the bearing will bind and overheat.
    11·1 answer
  • what do you expect the future trends of an operating system in terms of (a) cost (b) size (c) multitasking (d) portability (e) s
    12·1 answer
  • Explain the concept of energy conversion as applied to the generation of electricity also known as electrical energy​
    9·1 answer
  • Engineered lumber should not be used for
    15·1 answer
  • What is the correct procedure for mounting the m240 on the m122a1 tripod after the pintle is attached to the receiver?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!