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]
4 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]4 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
Which of the following best defines the term nanotechnology?
anastassius [24]
I had this quiz before. But The Answer Is C :)
4 0
3 years ago
Read 2 more answers
Consider steady heat transfer through the wall of a room in winter. The convection heat transfer coefficient at the outer surfac
AveGali [126]

The heat transfer which is in steady state, the heat transfer rate to the wall is equal to the wall.

<u>Explanation:</u>

  • The convection transfer of heat to the wall is

         Q=h A\left(T_{s}-T_{f}\right)

  • Here, T_{S} is the temperature of solid surface, T_{f} is the temperature of moving fluid stream which is adjacent of solid surface, h is the heat transfer coefficient.
  • The coefficient of convection heat transfers outer surface contains 3 times to the inner surface which experience smaller drop of temperature for 3 times that compares to inner surface.
  • Hence, the temperatures outer surface get close to the surroundings of air temperature.
6 0
3 years ago
PLEASE HELP, TEST MULTIPLE CHOICE QUESTIONS
Rina8888 [55]

Answer:

c

Explanation:

dbfjex vadamhqrmtwg

8 0
3 years ago
Read 2 more answers
Steam at 40 bar and 500o C enters the first-stage turbine with a volumetric flow rate of 90 m3 /min. Steam exits the turbine at
a_sh-v [17]

Answer:

(a) 62460 kg/hr

(b) 17,572.95 kW

(c) 3,814.57 kW

Explanation:

Volumetric flow rate, G = 30 m³ / 1 min => 90 / 60 => 1.5

Calculate for h₁ , h₂ , h₃

h₁ is h at P = 40 bar, 500°C => 3445.84 KJ/Kg

Specific volume steam, ц = 0.086441 m³kg⁻¹

h₂ is h at P = 20 bar, 400°C => 3248.23 KJ/Kg

h₃ is h at P = 20 bar, 500°C => 3468.09 KJ/Kg

h₄ is hg at P = 0.6 bar from saturated water table => 2652.85 KJ/Kg

a)

Mass flow rate of the steam, m = G / ц

m = 1.5 / 0.086441

m = 17.35 kg/s

mass per hour is m = 62460 kg/hr

b)

Total Power produced by two stages

= m (h₁ - h₂) + m (h₃ - h₁)

= m [(3445.84 - 3248.23) + (3468.09 - 2652.85)]

= m [ 197.61 + 815.24 ]

= 17.35 [1012.85]

= 17,572.95 kW

c)

Rate of heat transfer to the steam through reheater

= m (h₃ - h₂)

= 17.35 x (3468.09 - 3248.23)

= 17.35 x 219.86

= 3,814.57 kW

8 0
3 years ago
For this assignment, you will write a program to determine the time and date corresponding to an elapsed number of seconds since
Karolina [17]

A Python program should be written to produce output that corresponds to the given hour, minute, second, day of the month, month's name, year, and day of the week's name.

present_year=2016

present_month="January"

present_date="1"

present_day="Friday"

present_hour=0

present_minute=0

present_second=0

input<-from user(seconds)//taking imput from the user using Python program

   total_seconds=input

   //checking with seconds

   if(total_seconds<60)

       present_second+=total_seconds

   else

       total_minutes=total_seconds/60

       remaining_seconds=total_seconds-total_minutes*60

       present_second+=remaining_seconds

   //checking with minutes

   if(total_minutes<60)

       present_minute+=total_minutes

   else

       total_hours=total_minutes/60

       remaining_minutes=total_minutes-total_hours*60

       present_minute+=remaining_minutes

   //checklng with hours

   if(total_hours<24)

       present_hour+=total_hours

   else

       total_days=total_hours/24

       remaining_hours=total_hours-total_days*24

       present_hour+=remaining_hours

   //checking with days

   total_weeks=total_days/7

   remaining_day=total_days-total_weeks*7

   switch(remaining_day)

       case 1:

           present_day="Friday"

       case 2:

           present_day="Saturday"

       case 3:

           present_day="Sundayday"

       case 4:

           present_day="Monday"

       case 5:

           present_day="Tuesday"

       case 6:

           present_day="Wedday"

       case 7:

           present_day="Thursday"

   //checking with years    

   if(total_days>366)

       while(total_days)

           if(present_year%4==0)

               total_days-=366

               present_year+=1

           if(present_year%4!=4)

               total_days-=365

               present_year+=1

           if(present_year%4!=0&&total_days<365)

               break;

           if(present_year%4==0&&total_days<366)

               break;

   //checking with months and date

   if(total_days<=366)

       while(total_days)

           if(present_month="January")

               present_date++

               total_days--

               if(present_date==31)

                   present_month="February"

                   present_date=0

           if(present_month="February")

               present_date++

               total_days--

               if(present_date==28&&present_year%4!=0)

                   present_month="March"

                   present_date=0

               if(present_date==29&&present_year%4==0)

                   present_month="March"

                   present_date=0

           if(present_month="March")

               present_date++

               total_days--

               if(present_date==31)

                   present_month="April"

                   present_date=0        

           if(present_month="April")

               present_date++

               total_days--

               if(present_date==30)

                   present_month="May"

                   present_date=0        

           if(present_month="May")

               present_date++

               total_days--

               if(present_date==31)

                   present_month="June"

                   present_date=0        

           if(present_month="June")

               present_date++

               total_days--

               if(present_date==30)

                   present_month="July"

                   present_date=0    

           if(present_month="July")

               present_date++

               total_days--

               if(present_date==31)

                   present_month="August"

                   present_date=0    

           if(present_month="August")

               present_date++

               total_days--

               if(present_date==31)

                   present_month="September"

                   present_date=0        

           if(present_month="September")

               present_date++

               total_days--

               if(present_date==30)

                   present_month="October"

                   present_date=0    

           if(present_month="October")

               present_date++

               total_days--

               if(present_date==31)

                   present_month="November"

                   present_date=0    

           if(present_month="November")

               present_date++

               total_days--

               if(present_date==30)

                   present_month="December"

                   present_date=0

           if(present_month="December")

               present_date++

               total_days--

               if(present_date==31)

                   present_month="January"

                   present_date=0

//printing present time

print present_hour:present_minute:present_second present_date present_month present_year present_day          

Learn more about Python program here:

brainly.com/question/28691290

#SPJ4          

3 0
1 year ago
Other questions:
  • The principal value of a Pareto diagram is as a
    14·1 answer
  • The three areas of knowledge that are required for a product safety engineer are:
    6·1 answer
  • For all substances, Cp&gt;C. Why is that?
    15·1 answer
  • A mass of 1.9 kg of air at 120 kPa and 24°C is contained in a gas-tight, frictionless piston–cylinder device. The air is now com
    7·1 answer
  • Instruments in airplane A indicate that with respect to the air the plane is headed 30◦ north of east with an airspeed of 300 mi
    5·1 answer
  • Suppliers(sid: integer, sname: string, address: string)
    9·1 answer
  • What are the use of logic gates in the field of robotics?
    10·1 answer
  • PLEASE PLEASE PLEASE HELP
    9·1 answer
  • What color is an orange? its for my 8th grade
    13·1 answer
  • Need help, I will give cake :))<br><br> + branliest
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!