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
xxMikexx [17]
3 years ago
14

Write a program to simulate the design process of the course. First, create a struct for the course which consists of following

members: course number (int type, e.g. 1200), course start date (int type, e.g. 20200107), course hours (int type, how many hours per week) and lecturer ID (int type). Second, create a struct for lecturer, which has following members: lecturer ID (int type), lecturer office hours (int type, how many office hours per week) and course teaching(array[int] type). Third, create a struct for student, which as following members: student ID (int type), course taken (array[int type). Then answer following questions 1, 2 and 3 based on these structures: 1. The department decide to offer three courses in a semester: 1000, 1100 and 1200. Please create these courses with structs you defined above. Their information is given below: Course number Course start date Course hours Lecturer ID 1000 20200107 2 100 1100 20200113 4 200 1200 20200203 4 100 2. Department also assigned two lecturers to teach these courses. Please create documents for lecturers and print out the information for both lectures on the screen. Note: Each lecturer will be assigned 2 hours office hours for each course he/she teaches. 3. A student, whose ID is 2000, are considering taking 2 courses among above courses. Please print out how many course hours he/she needs to take each week. Note, simply add up the course hours from table in question 1 will not be considered as correct answer. Your program should first ask this student to input the course number he/she registered, then print the total course hours. 4. Conduct an experiment with Arduino using an Angle Rotary Sensor and a Servo (connect sensors to Arduino appropriately). The Angle Rotary Sensor must control the movement of the Servo. In other words, when you change the angle of the Rotary Angle Sensor (0 to 300 degrees), the Servo will rotate the short white blade accordingly after mapping the Angle Rotary Sensor value (0 to 300 to a Servo position (0 to 180). Also, display the angle degree of the Angle Rotary Sensor and the position of the Servo on the Serial Monitor window. Use Serial.print function to print on the Serial Monitor window, which can be open by clicking on the icon- on the upper right area of the Arduino window. Also, you need to use the following statement in the setup function: Serial.begin(9600);
Computers and Technology
1 answer:
Dmitry [639]3 years ago
4 0

Answer:

#include <iostream>

using namespace std;

struct Course

{

int courseNumber;

int courseStartDate;

int courseHours;

int lecturerId;

};

struct Lecturer

{

int lecturerId;

int officeHours;

Course courseTeaching[2];

};

struct Student

{

int studentId;

Course coursesTaken[2];

};

int main()

{

Course courseObj1, courseObj2, courseObj3;

courseObj1.courseNumber = 1000;

courseObj1.courseStartDate = 20200107;

courseObj1.courseHours = 2;

courseObj1.lecturerId = 100;

courseObj2.courseNumber = 1100;  

courseObj2.courseStartDate = 20200113;

courseObj2.courseHours = 4;

courseObj2.lecturerId = 200;

courseObj3.courseNumber = 1200;

courseObj3.courseStartDate = 20200203;

courseObj3.courseHours = 4;

courseObj3.lecturerId = 100;

Lecturer lecturerObj1, lecturerObj2;

lecturerObj1.lecturerId = 100;

lecturerObj1.officeHours = 2;

lecturerObj1.courseTeaching[0] = courseObj1;

lecturerObj1.courseTeaching[1] = courseObj3;

lecturerObj2.lecturerId = 200;

lecturerObj2.officeHours = 2;

lecturerObj2.courseTeaching[0] = courseObj2;

Student student;

student.studentId = 2000;

student.coursesTaken[0] = courseObj1;

student.coursesTaken[1] = courseObj3;

cout << "1. Lecturer ID: " << lecturerObj1.lecturerId << "\tOffice Hours: " << lecturerObj1.officeHours << endl;

for(int i = 0; i < 2; i++)

cout << "COURSE " << (i + 1) << ":\n---------\n" << "Course Number: " << lecturerObj1.courseTeaching[i].courseNumber << endl << "Course start date: " << lecturerObj1.courseTeaching[i].courseStartDate << endl << "Course hours: " << lecturerObj1.courseTeaching[i].courseHours << endl << "Lecturer ID: " << lecturerObj1.courseTeaching[i].lecturerId << endl;

cout << "\n2. Lecturer ID: " << lecturerObj2.lecturerId << "\tOffice Hours: " << lecturerObj2.officeHours << endl;

for(int i = 0; i < 1; i++)

cout << "COURSE " << (i + 1) << ":\n---------\n" << "Course Number: " << lecturerObj2.courseTeaching[i].courseNumber << endl << "Course start date: " << lecturerObj2.courseTeaching[i].courseStartDate << endl << "Course hours: " << lecturerObj2.courseTeaching[i].courseHours << endl << "Lecturer ID: " << lecturerObj2.courseTeaching[i].lecturerId << endl;

int courseNumber;

cout << "\n Enter the course number: ";

cin >> courseNumber;

int index = -1;

int len = sizeof(student.coursesTaken) / sizeof(student.coursesTaken[0]);

int totalHours = 0;

for(int i = 0; i < len; i++)

{

if(student.coursesTaken[i].courseNumber == courseNumber)

{

totalHours += student.coursesTaken[i].courseHours;

}

}

if(totalHours == 0)

cout << "\n Student is not registered to this course!\n";

else

cout << "\nStudent " << student.studentId << " needs " << totalHours << " hours per week of this course.\n";

return 0;

}

Explanation:

  • Create the 3 objects of Course class and set their properties respectively.
  • Create the 2 objects of Lecturer class and set their properties respectively.
  • Create an object of Student class and set their properties respectively.
  • Run a for loop and check whether the current courseNumber is already added and then increment the total number of hours for that course.
  • Finally check if totalHours is equal to 0 or not and then display the suitable message accordingly.
You might be interested in
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
sdas [7]

Answer:

The modified program in Python is as follows:

import math

paint_colors = {'red': 35,'blue': 25,'green': 23}

wall_height = int(input('Enter wall height (feet):\n'))

wall_width = int(input('Enter wall width (feet):\n'))

area = wall_height*wall_width

print('Wall area:',area,'square feet')

paint_needed = area/350.0

print('Paint needed: {:.2f} gallons'.format(paint_needed))

print('Cans needed:',round(paint_needed),'can(s)')

color = input("Choose a color to paint the wall: ")

print("Cost of purchasing", color, "paint: $",paint_colors[color])

Explanation:

The italicized are given from the question [unchanged]

<em>import math</em>

<em> paint_colors = {'red': 35,'blue': 25,'green': 23} </em>

<em>wall_height = int(input('Enter wall height (feet):\n')) </em>

This gets input for width

wall_width = int(input('Enter wall width (feet):\n'))

Calculate the wall area

area = wall_height*wall_width

Print the calculated wall area

print('Wall area:',area,'square feet')

Calculate the amount of paint needed

paint_needed = area/350.0

Print the amount of paint needed to 2 decimal places

print('Paint needed: {:.2f} gallons'.format(paint_needed))

Print the amount of can needed to nearest integer

print('Cans needed:',round(paint_needed),'can(s)')

Prompt user for color of paint [here, we assume the user input is correct]

color = input("Choose a color to paint the wall: ")

Prints the corresponding amount for the color

print("Cost of purchasing", color, "paint: $",paint_colors[color])

3 0
3 years ago
EASY QUESTION EASY POINTS!!!!! WILL MARK BRAINLIEST!!!!!
TEA [102]

The program is an illustration of loops and conditional statements

<h3>Loops</h3>

Loops are used to perform repetitive operations.

<h3>Conditional statement</h3>

Conditional statements are used to make decisions

<h3>The python program</h3>

The program in Python, where comments are used to explain each line is as follows.

#The following is repeated 5 times; i.e. the rows

for i in range(5):

   #The following is repeated 5 times; i.e. the columns

   for j in range(5):

       #For rows 2 and 5

       if i == 1 or i== 3:

           #For columns 1 and 5

           if j == 0 or j == 4:

               #This prints *

               print('*',end='')

           #For other columns

           else:

               #This prints an empty space

               print('',end=' ')

       #For other rows

       else:

           #This prints *

           print('*',end='')

   #This prints a new line

   print()

Read more about loops at:

brainly.com/question/19344465

5 0
3 years ago
A petrol (gas) station is to be set up for fully automated operation. A driver inputs his or her credit card into the pump, the
malfutka [58]

Answer:

Explanation:

Gas Filling Station has pumps. Pumps have credit card readers. Driver can able to swipe their cards, pumps have Fuel. Pumps card readers communicate with Credit Company. Driver interacts with pump for fuel and credit card.

In this situation the following we need to treat as objects.

They are Pump, Card reader, Fuel tank, communication system, system controller and price table.

Design pattern for the following system is attached below

6 0
4 years ago
To check spelling errors in a document, the Word application uses the _____ to determine appropriate spelling. Internet built-in
Ilya [14]

The answer is built-in dictionary.

Most Microsoft Word versions come with a built-in dictionary for standard grammar and spellings. These dictionaries are not comprehensive. Word also has an additional option to add a spelling error to the dictionary so that the next time you type that same error, it will not come up as a spelling error. In addition, Word can use multiple custom dictionaries that allows you to supplement with the main dictionary and check the spelling of your documents.

6 0
3 years ago
Read 2 more answers
Where could identity theft access your personal information?
riadik2000 [5.3K]
From hacking into public websites where you pay and stuff, or put in a fake official window to lure out your private info.
6 0
3 years ago
Read 2 more answers
Other questions:
  • You can create a ____ partition to hold files that are created temporarily, such as files used for printing documents (spool fil
    11·1 answer
  • I just started game development using unity, I’m trying to control my sphere moving on a flat surface using the W,A,S,D keys, if
    5·1 answer
  • PLEASE HELP ASAP!!!
    8·1 answer
  • In the ____________________ approach, the project is initiated by upper-level managers who issue policy, procedures and processe
    8·1 answer
  • In general, digital to analog modulation equipment is less expensive than the equipment for encoding digital data into a digital
    8·1 answer
  • When searching for an image on your computer, you should look for a file with which of the following extensions?
    8·1 answer
  • Given a number count the total number of digits in a number
    12·1 answer
  • A set of blocks contains blocks of heights 1,2, and 4 centimeters. Imagine constructing towers of piling blocks of different hei
    15·1 answer
  • I need help with this line of code:
    5·1 answer
  • The RGB value below produces a shade of purple. What does the number 175
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!