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
When framing a building, a simple way to estimate the total amount of wall studs needed is to allow
Levart [38]
1+1=2
Solution
3:932(2)=61
4 0
3 years ago
One gram of Strontium-90 has an activity of 5.3 terabecquerels (TBq), what will be the activity of 1 microgram?
noname [10]

1 micro gram of Strontium-90 has an activity of

0.0000053 terabecquerels (TBq),

Explanation:

Given information denotes that .,one gram of Strontium-90 has an activity of 5.3 terabecquerels (TBq)

the activity of 1 micro gram is

1 gram = 1,000,000 micro gram has activities of 5.3 terabecquerels

therefore 1 micro gram has the activity of (5.3 ÷  1,000,000 = 0.0000053 )

= (5.3 ÷  1,000,000 = 0.0000053 )

Hence ., 1 micro gram of Strontium-90 has an activity of

0.0000053 terabecquerels (TBq),

8 0
3 years ago
A large tank is filled to capacity with 500 gallons of pure water. Brine containing 2 pounds of salt per gallon is pumped into t
Nataly [62]

Answer:

A) A(t) = 10(100 - t) + c(100 - t)²

B) Tank will be empty after 100 minutes.

Explanation:

A) The differential equation of this problem is;

dA/dt = R_in - R_out

Where;

R_in is the rate at which salt enters

R_out is the rate at which salt exits

R_in = (concentration of salt in inflow) × (input rate of brine)

We are given;

Concentration of salt in inflow = 2 lb/gal

Input rate of brine = 5 gal/min

Thus;

R_in = 2 × 5 = 10 lb/min

Due to the fact that the solution is pumped out at a faster rate, thus it is reducing at the rate of (5 - 10)gal/min = -5 gal/min

So, after t minutes, there will be (500 - 5t) gallons in the tank

Therefore;

R_out = (concentration of salt in outflow) × (output rate of brine)

R_out = [A(t)/(500 - 5t)]lb/gal × 10 gal/min

R_out = 10A(t)/(500 - 5t) lb/min

So, we substitute the values of R_in and R_out into the Differential equation to get;

dA/dt = 10 - 10A(t)/(500 - 5t)

This simplifies to;

dA/dt = 10 - 2A(t)/(100 - t)

Rearranging, we have;

dA/dt + 2A(t)/(100 - t) = 10

This is a linear differential equation in standard form.

Thus, the integrating factor is;

e^(∫2/(100 - t)) = e^(In(100 - t)^(-2)) = 1/(100 - t)²

Now, let's multiply the differential equation by the integrating factor 1/(100 - t)².

We have;

So, we ;

(1/(100 - t)²)(dA/dt) + 2A(t)/(100 - t)³ = 10/(100 - t)²

Integrating this, we now have;

A(t)/(100 - t)² = ∫10/(100 - t)²

This gives;

A(t)/(100 - t)² = (10/(100 - t)) + c

Multiplying through by (100 - t)²,we have;

A(t) = 10(100 - t) + c(100 - t)²

B) At initial condition, A(0) = 0.

So,0 = 10(100 - 0) + c(100 - 0)²

1000 + 10000c = 0

10000c = -1000

c = -1000/10000

c = -0.1

Thus;

A(t) = 10(100 - t) + -0.1(100 - t)²

A(t) = 1000 - 10t - 0.1(10000 - 200t + t²)

A(t) = 1000 - 10t - 1000 + 20t - 0.1t²

A(t) = 10t - 0.1t²

Tank will be empty when A(t) = 0

So, 0 = 10t - 0.1t²

0.1t² = 10t

Divide both sides by 0.1t to give;

t = 10/0.1

t = 100 minutes

6 0
3 years ago
A coal fired power plant geneartes 2.4 lbs. of CO2 per kWh. A lighting system consumes 300,000kWh per year. A corporation is con
Serjik [45]

Answer:

The perceived economic impact of CO2 generated per year by lighting sstem is $8164.67.

Explanation:

The CO2 requirement for the plant is:

Amount of CO2 per year = (2.4 lb / KWh)(300,000 KWh)

Amount of CO2 per year = (720000 lb)(1 ton/ 2204.62 lb)

Amount of CO2 per year = 326.59 ton

The perceived economic impact of CO2 generated per year will then be:

Economic Impact = ($25 / ton)(326.59 ton)

<u>Economic Impact = $8164.67</u>

7 0
3 years ago
Outline the structure of an input-output model (including assumptions about supply and demand). What is an inverse matrix? Why i
pishuonlain [190]

Answer:

Explanation:

C.1 Input-Output Model

It is a formal model that divides the economy into 2 sectors and traces the flow of inter-industry purchases and sales. This model was developed by Wassily Leontief in 1951. In simpler terms, the inter-industry model is a quantitative economic model that defines how the output of one industry becomes the input of another industrial sector. It is an interdependent economic model where the output of one becomes the input of another. For Eg: The Agriculture sector produces output using the inputs from the manufacturing sector.

The 3 main elements are:

Concentrates on an economy which is in equilibrium

Deals with technical aspects of production

Based on empirical investigations and assumptions

Assumptions

2 sectors - " Inter industry sector" and "final sector"

Output of one industry is the input for another

No 2 goods are produced jointly. i.e each industry produces homogenous goods

Prices, factor suppliers and consumer demands are given

No external economies or diseconomies of production

Constant returns to scale

The combinations of inputs are employed in rigidly fixed proportions.

Structure of IO model

See image 1

Quadrant 1: Flow of products which are both produced and consumed in the process of production

Quadrant 2: Final demand for products of each producing industry.

Quadrant 3: Primary inputs to industries (raw materials)

Quadrant 4: Primary inputs to direct consumption (Eg: electricity)

The model can be used in the analysis of the labor market, forecast economic development of a nation and analyze economic developments of various regions.

Leontief inverse matrix shows the output rises in each sector due to a unit increase in final demand. Inverting the matrix is significant since it is a linear system of equations with unique solutions. Thus, the final demand vector for the required output can be found.

C.2 Linear programming problems

Linear programming problems are optimization problems in which objective function and the constraints are all linear. It is most useful in making the best use of scarce resources during complex decision makings.

Primal LP, Dual LP, and Interpretations

Primal linear programming: They can be viewed as a resource allocation model that seeks to maximize revenue under limited resources. Every linear program has associated with it a related linear program called dual program. The original problem in relation to its dual is termed as a primal problem. The objective function is a linear combination of n variables. There are m constraints that place an upper bound on a linear combination of the n variables The goal is to maximize the value of objective functions that are subject to the constraints. If the primal linear programming has finite optimal value, then the dual has finite optimal value, and the primal and dual have the same optimal value. If the optimal solution to the primal problem makes a constraint into a strict inequality, it implies that the corresponding dual variable must be 0. The revenue-maximizing problem is an example of a primal problem.

Dual Linear Programming: They represent the worth per unit of resource. The objective function is a linear combination of m values that are the limits in the m constraints from the primal problem. There are n dual constraints that place a lower bound on a linear combination of m dual variables. The optimal dual solution implies fair prices for associated resources. Stri=ong duality implies the Company’s maximum revenue from selling furniture = Entrepreneur’s minimum cost of purchasing resources, i.e company makes no profit. Cost minimizing problem is an example of dual problems

See image 2

n - economic activities

m - resources

cj - revenue per unit of activity j

4 0
3 years ago
Read 2 more answers
Other questions:
  • A 1-lb collar is attached to a spring and slides without friction along a circular rod in a vertical plane. The spring has an un
    6·1 answer
  • Find the thickness of the material that will allow heat transfer of 6706.8 *10^6 kcal during the 5 months through the rectangle
    8·1 answer
  • Line layout is also called ......​
    5·1 answer
  • Convection is a function of temperature to the fourth power. a)-True b)-False
    9·1 answer
  • You are a technical writer for Landson Toy Company. Landson has just designed a new, more durable swing set for 6- to 10-year-ol
    9·1 answer
  • An Otto cycle with air as the working fluid has a compression ratio of 8.2. Under cold air standard conditions, what is the ther
    14·1 answer
  • At least 1 sources must be from an organization website (.org) and 1 source must be from and educational website .edu) Do not us
    7·1 answer
  • You installed a new 40 gallon water heater with a 54,000 BTUh burner. The underground water temperature coming into the house is
    9·1 answer
  • Which organization would provide business and leadership training to a high school hospitality student?
    6·1 answer
  • The most important reason to wear your seat belt is to protect you from:
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!