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
If Ella decided to become a children’s doctor, what career cluster would she belong in?
vodomira [7]
D . Health Services
8 0
2 years ago
Calculate the load, PP, that would cause AA to be displaced 0.01 inches to the right. The wires ABAB and ACAC are A36 steel and
Nataly [62]

Answer:

P = 4.745 kips

Explanation:

Given

ΔL = 0.01 in

E = 29000 KSI

D = 1/2 in  

LAB = LAC = L = 12 in

We get the area as follows

A = π*D²/4 = π*(1/2 in)²/4 = (π/16) in²

Then we use the formula

ΔL = P*L/(A*E)

For AB:

ΔL(AB) = PAB*L/(A*E) = PAB*12 in/((π/16) in²*29*10⁶ PSI)

⇒  ΔL(AB) = (2.107*10⁻⁶ in/lbf)*PAB

For AC:

ΔL(AC) = PAC*L/(A*E) = PAC*12 in/((π/16) in²*29*10⁶ PSI)

⇒  ΔL(AC) = (2.107*10⁻⁶ in/lbf)*PAC

Now, we use the condition

ΔL = ΔL(AB)ₓ + ΔL(AC)ₓ = ΔL(AB)*Cos 30° + ΔL(AC)*Cos 30° = 0.01 in

⇒  ΔL = (2.107*10⁻⁶ in/lbf)*PAB*Cos 30°+(2.107*10⁻⁶ in/lbf)*PAC*Cos 30°= 0.01 in

Knowing that   PAB*Cos 30°+PAC*Cos 30° = P

we have

(2.107*10⁻⁶ in/lbf)*P = 0.01 in

⇒  P = 4745.11 lb = 4.745 kips

The pic shown can help to understand the question.

5 0
3 years ago
Give two causes that can result in surface cracking on extruded products.
Andreas93 [3]

Answer:

1. High friction

2. High extrusion temperature

Explanation:

Surface cracking on extruded products are defects or breakage on the surface of the extruded parts. Such cracks are inter granular.

           Surface cracking defects arises from very high work piece temperature that develops cracks on the surface of the work piece. Surface cracking appears when the extrusion speed is very high, that results in high strain rates and generates heat.

          Other factors include very high friction that contributes to surface cracking an d chilling of the surface of high temperature billets.

6 0
3 years ago
. In order to prevent injury from inflating air bags, it is recommended that vehicle occupants sit at least __________ inches aw
scZoUnD [109]
10 inches is the answer
8 0
2 years ago
Read 2 more answers
An FPC 4 m2 in area is tested during the night to measure the overall heat loss coefficient. Water at 60 C circulates through th
sp2606 [1]

Answer:

<em> - 14.943 W/m^2K  ( negative sign indicates cooling ) </em>

Explanation:

Given data:

Area of FPC = 4 m^2

temp of water = 60°C

flow rate = 0.06 l/s

ambient temperature = 8°C

exit temperature = 49°C

<u>Calculate the overall heat loss coefficient </u>

Note : heat lost by water = heat loss through convection

m*Cp*dT  = h*A * ( T - To )

∴ dT / T - To = h*A / m*Cp  ( integrate the relation )

In ( \frac{49-8}{60-8} ) =  h* 4 / ( 0.06 * 10^-3 * 1000 * 4180 )

In ( 41 / 52 ) = 0.0159*h

hence h = - 0.2376 / 0.0159

              = - 14.943  W/m^2K  ( heat loss coefficient )

7 0
2 years ago
Other questions:
  • What is centrifugal force with respect to unbalance? What is the formula used to determine centrifugal force?
    12·1 answer
  • What happens to a commercial airline at cruising altitude if the pilot does not touch the throttles?
    12·1 answer
  • The amount of time an activity can be delayed and yet not delay the project is termed:_________
    14·1 answer
  • List two common units of measurement to describe height
    5·2 answers
  • Which type of blade is used with a demolition saw?
    11·1 answer
  • What is the reading of this Dial Caliper?
    9·1 answer
  • If my current directory is ‘AR’ write the path for my current directory
    5·1 answer
  • Which of the following was a sustainable power source used during the Middle Ages?
    9·2 answers
  • The actual tracking weight of a stereo cartridge that is set to track at 3 g on a particular changer can be regarded as a contin
    9·1 answer
  • Integrated circuits typically are mounted on ________, which are then plugged into the system board.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!