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
By using order of magnitude analysis, the continuity and Navier-Stokes equations can be simplified to the Prandtl boundary-layer
Mademuasel [1]

Answer: Attached below is the well written question and solution

answer:

i) Attached below

ii) similar parameter =  \frac{V}{VoL } = 1 / Re

Explanation:

Using ;  L as characteristic length and Vo as reference velocity

i) Nondimensionalize the equations

ii) Identifying similarity parameters

the similar parameters are  = \frac{V}{VoL } = 1 / Re

Attached below is the detailed solution

7 0
2 years ago
A 15-ft beam weighing 570 lb is lowered by means of two cables unwinding from overhead cranes. As the beam approaches the ground
7nadin3 [17]

Answer:

I. Tension (cable A) ≈ 6939 lbf

II. Tension (cable B) ≈ 17199 lbf

Explanation:

Let's begin by listing out the data that we were given:

mass of beam (m) = 570 lb, deceleration (cable A) = -20 ft/s², deceleration (cable B) = -2 ft/s²,

g = 32.17405 ft/s²

The tension on an object is given by the product of mass of the object by gravitational force plus/minus the product of mass by acceleration.

Mathematically represented thus:

T = mg + ma

where:

T = tension, m = mass, g = gravitational force,

a = acceleration

I. For Cable A, we have:

T = mg + ma = (570 * 32.17405) + [570 * (-20)]

T = 18339.2085 - 11400 = 6939.2085

T ≈ 6939 lbf

II. For Cable B, we have:

T = mg + ma = (570 * 32.17405) + [570 * (-2)]

T = 18339.2085 - 1140 = 17199.2085

T ≈ 17199 lbf

4 0
3 years ago
The waffle slab is: a) the two-way concrete joist framing system. b) a one-way floor and roof framing system. c) the one-way con
GREYUIT [131]

Answer:

a) the two-way concrete joist framing system

Explanation:

A waffle slab is also known as ribbed slab, it is a slab which as waffle like appearance with holes beneath. It is adopted in construction projects that has long length, length more than 12m. The waffle slab is rigid, therefore it is used in building that needs minimal vibration.

4 0
3 years ago
HELP PLEASE!!!!!!!!!!!
MAXImum [283]
C is your answers!!!!!$3&2)//
7 0
3 years ago
Read 2 more answers
What tools are used to build a watch tower PLEASE HELP ME​
harkovskaia [24]

Answer:

The trunks were all cut at the same lenght, 9 Carolingian feet, easier to carry away and to build. The construction was built by a team of four people, using traditional tools such as a hand saw, clamp, gimlet, Catalan type axe, wood hammer, chisel, two-handed wood saw, heavy wood hammer and metal wedges.

Explanation:

8 0
2 years ago
Other questions:
  • An inflatable structure has the shape of a half-circular cylinder with hemispherical ends. The structure has a radius of 40 ft w
    6·1 answer
  • A man weighs 145 lb on earth.Part ASpecify his mass in slugs.Express your answer to three significant figures and include the ap
    11·1 answer
  • If x &lt; 5 and x &gt;c, give a value of c such that there
    9·1 answer
  • All circuits need three basic parts: an energy source, wires, and the object that is going to change the electrical energy into
    5·2 answers
  • Air is compressed steadily from 100kPa and 20oC to 1MPa by an adiabatic compressor. If the mass flow rate of the air is 1kg/s an
    12·1 answer
  • What would happen if the brake pedal was released while the bleed screw was open during brake bleeding?
    7·1 answer
  • Rod of steel, 200 mm length reduces its diameter (50 mm) by turning by 2 mm with feed speed 25 mm/min. You are required to calcu
    11·1 answer
  • Tech A says that a mechanical pressure regulator exhausts excess fluid back to the transmission pan. Tech B says that if the tra
    9·1 answer
  • 3. Determine the most unfavorable arrangement of the crane loads and
    6·1 answer
  • Draw the free-body diagram of the beam which supports the 80-kg load and is supported by the
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!