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
Firlakuza [10]
3 years ago
12

Write a C++ program that creates a map containing course numbers and the room numbers of the rooms where the courses meet. The d

ictionary should have the following key-value pairs:
Course Number (key) Room Number (value)
CS101 3004
CS102 4501

The program should also create a map containing course numbers and the names of the instructors that teach each course. The map should have the following key-value pairs:

Course Number (key) Instructor (value)
CS101 Haynes
CS102 Alvarado

The program should also create a map containing course numbers and the meeting times of each course. The map should have the following key-value pairs:

Course Number (key) Meeting Time (value)
CS101 8:00am
CS102 9:00am

The program should let the user enter a course number, and then it should display the course's room number, instructor, and meeting time.
Computers and Technology
1 answer:
swat323 years ago
7 0

Answer:

Program approach:-

  • Using the necessary header file.
  • Using the standard namespace I/O.
  • Define the integer main function.
  • Mapping course numbers and room numbers.

Explanation:

//header file

#include<iostream>

#include<map>

//using namespace

using namespace std;

//main function

int main(){

               //creating 3 required maps

               map <string,int> rooms;

               map <string,string> instructors;

               map <string,string> times;

               //mapping course numbers and room numbers

               rooms.insert(pair<string,int>("CS101",3004));

               rooms.insert(pair<string,int>("CS102",4501));

               //mapping course numbers and instructor names

               instructors.insert(pair<string,string>("CS101","Haynes"));

               instructors.insert(pair<string,string>("CS102","Alvarado"));

               //mapping course numbers and meeting times

               times.insert(pair<string,string>("CS101","8:00am"));

               times.insert(pair<string,string>("CS102","9:00am"));

               

               char choice='y';

               //looping until user wishes to quit

               while(choice=='y' || choice=='Y'){

                               cout<<"Enter a course number: ";

                               string course;

                               cin>>course;//getting course number

                               //searching in maps for the required course number will return

                               //an iterator

                               map<string, int>::iterator it1=rooms.find(course);

                               map<string, string>::iterator it2=instructors.find(course);

                               map<string, string>::iterator it3=times.find(course);

               

                               if(it1!=rooms.end()){

                                               //found

                                               cout<<"Room: "<<it1->second<<endl;

                               }else{

                                               //not found

                                               cout<<"Not found"<<endl;

                               }

               

                               if(it2!=instructors.end()){

                                               cout<<"Instructor: "<<it2->second<<endl;

                               }

               

                               if(it3!=times.end()){

                                               cout<<"Meeting Time: "<<it3->second<<endl;

                               }

                               //prompting again

                               cout<<"\nDo you want to search again? (y/n): ";

                               cin>>choice;

               }

You might be interested in
What steps are needed for word to create an index
8_murik_8 [283]

Answer:

Do this:

Position the insertion pointer where you want the index to appear. If you want the index to start on a new page, create a new page in Word. ...

Click the References tab.

In the Index group, click the Insert Index button. The Index dialog box appears. ...

Click the OK button to insert the index into your document.

4 0
3 years ago
Read 2 more answers
John would like to move from the city into the suburbs and has been saving up a large down payment for a home. Which is the most
fenix001 [56]
I there any answer choices ?


5 0
4 years ago
What does a mother board in a computer do?
IRINA_888 [86]

The motherboard is the central component of a computer. Without it, the computer would not work. The mother board is sometimes called "the heart of the computer" because it allows thinks to function properly.

The motherboard of the computer is the part that holds the system memory and audio. It's a printed circuit board.

4 0
3 years ago
Engineers are problem-solvers who use math, science, creativity and other knowledge and skills to solve problems. They use every
Elena-2011 [213]
Different types of engineers solve different kinds of problems. A mechanical engineer might design a rollercoaster that is fun and safe using knowledge of physics and mechanics,

this person is an engineer

just so u know I don't know if this is correct
8 0
3 years ago
Read 2 more answers
Compare physical storage and virtual storage. Give an example of each and explain why one type allows computers to access data a
Nuetrik [128]
Physical storage is like your Hard Drive, Virtual is what is called the Cloud. Hard drives are able to pull information directly from inside the computer while the cloud has to do over the internet.
8 0
4 years ago
Other questions:
  • You want to discard your old computer but want to securely erase the data from your hard drive, what can Use to do this?
    5·1 answer
  • 6.6 Write a function named timesTen. The function should have an integer parameter named number. When timesTen is called, it sho
    7·1 answer
  • Give an example of an outdated memory or storage device what do you think they are outdated
    12·1 answer
  • 1000base-t is a standard for achieving throughputs ____ times faster than fast ethernet over copper cable.
    8·1 answer
  • Write a test program that prompts the user to enter three sides of the triangle (make sure they define an actual triangle), a co
    5·1 answer
  • What is the function of the NOS? Select all that apply.
    5·2 answers
  • QBasic commands any 10 with examples
    5·1 answer
  • Write a method that takes a Rectangle as a parameter, and changes the width so it becomes a square (i.e. the width is set to the
    8·1 answer
  • What is game development​
    10·2 answers
  • Despite a wide variety of workplaces for those working in Human Services, all workplaces include
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!