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]
2 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:
swat322 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
Many organizations find themselves in the position of being data rich and information poor. Even in today's electronic world, ma
juin [17]

Answer:True

Explanation:

Many organizations find themselves in the position of being data rich and information poor. Even in today's electronic world, managers struggle with the challenge of turning their business data into business intelligence.Data in its raw form does not help managers in reaching their business decisions. In this electronic age data collection has been made simple .However the value of that data can only be seen when it is processed and it becomes information. It can help managers to make quick business decisions that will be used to make come up with important business strategies  .It follows that when data is collected in its various forms it should then be processed meaning that the business managers can either use business Intelligent software  that can present the data in a meaningful form like graphs . pie charts and other forms that can be easily interpreted and reflect the trends that have been presented by the raw data .The organisation should find value in the data that they have collected and tell the story that leaves in the data.

7 0
2 years ago
Write a program in c or c++ to perform different arithmeticoperation using switch statement .the program will take two inputinte
baherus [9]

Answer:

C code :

#include<stdio.h>

int main()

{

int j;

float k,l, x;  //taking float to give the real results.

printf("Enter your two operands: ");  //entering the numbers on which      //the operation to be performed.

scanf("%f %f", &k, &l);

 

printf("\n Now enter the operation you want to do: ");

printf("1 for Addition, 2 for Subtraction, 3 for Multiplication, 4 for Division ");

scanf("%d", &j);  //j takes the input for opearation.

 

switch(j)  

{

 case 1:  

  x=k+l;

  printf("%.2f+%.2f=%.2f",k,l,x);   //we write %.2f to get the result //upto 2 decimal point.

  break;

   

 case 2:

  x=k-l;

  printf("%.2f-%.2f=%.2f",k,l,x);

  break;

 case 3:

  x=k*l;

  printf("%.2f*%.2f=%.2f",k,l,x);

  break;

 case 4:

  if(l!=0) //division is not possible if the denominator is 0.

  {

   x=k/l;

   printf("%.2f/%.2f=%.2f",k,l,x);

  }

  else  

   printf("Division result is undefined");

               default:

   printf("\n invalid operation");

}

}

Output is in image.

Explanation:

At first we take two numbers.

Then we take integers from 1 to 4 for Addition, subtraction, multiplication, division respectively.

Then accordingly the case is followed and the operation is performed.

6 0
3 years ago
Alright, so im currently trying to pass a computer science class. i need it done in a little under 2 weeks. Ill just ask the one
Alla [95]

Answer:

B. Mesh

Explanation:

5 0
3 years ago
"Switches break up _______________ domains and routers break up _____________ domains."
mel-nik [20]

Answer:

Switches break up collision domains and routers break up broadcast domains.

Explanation:

  • Collision domain depicts the part within a network where a collision can happen.
  • Collision occurs when two hosts transmit data packet at the same time within a network. Theses packets collide and the hosts have to resend the data after some time.
  • Too many collisions can result in slow traffic speed and can effect network performance.
  • So switches break up collision domains between the devices on a network and each port in a switch depicts a collision domain. This reduces the chance of packet collisions between the devices or hosts.
  • When data is to be sent to a host, the switch keeps that data frame and waits for availability of the destination host before sending the data frame.
  • Moreover full duplex switch mode there is not chance of collision as the transmitting path on one host is the receiving path on other host.
  • Broadcast domain contains all the hosts that can reach each other at the Data Link layer via broadcast.
  • Routers break up broadcast domains as routers contain separate broadcast domains for each interface.
  • Routers do not forward broadcasts from one broadcast domain to other and drop the packet when they detect a broadcast address.
4 0
3 years ago
Assume you are given three variables, revenue, expenses, and profit, all of type Money (a structured type with two int fields, d
Andre45 [30]

Answer:

if(revenue.cents - expenses.cents < 0){

profit.dollars = revenue.dollars - expenses.dollars - 1;

profit.cents = 1 - revenue.cents - expenses.cents;

}

else{

profit.dollars = revenue.dollars - expenses.dollars;

profit.cents = revenue.cents - expenses.cents;

}

Explanation:

We know that profit is given as: revenue - expenses from the question.

From the given expression above;

if(revenue.cents - expenses.cents < 0)

then profit.dollar will be revenue.dollars - expenses.dollars - 1; the 1 is to be carry over to the cent part. And the profit.cent will be 1 - revenue.cents - expenses.cents;

else the profit.dollars and the profit.cent is computed directly without needing to carry over:

profit.dollars = revenue.dollars - expenses.dollars;

profit.cents = revenue.cents - expenses.cents;

7 0
2 years ago
Other questions:
  • It is okay to use a dust rag when cleaning the inside of a computer.
    9·2 answers
  • Mica's creating his web page with a software that is free of charge for the first month. If he likes the program, he will have t
    8·2 answers
  • Juliet is trying to increase her savings account and she decides that she is going save an additional $700 every month. If her m
    9·1 answer
  • In this exercise, you are given a phrase and need to return that phrase in all capital letters.
    6·1 answer
  • When you want to avoid sending email that a recipient may feel their privacy has been invaded, how would you fill in the (To) bo
    13·1 answer
  • What is the name of the program file that you can enter in the Windows search or Run box to execute Event Viewer? What process i
    12·1 answer
  • The method needed to arrange for an object to be notified when a window's close-window button has been clicked is
    6·1 answer
  • . Which of the following is NOT a valid declaration for a character string?
    6·1 answer
  • Write a program that takes a decimal number from the user and then prints the integer part and the decimal part separately. For
    13·1 answer
  • Which of the following statements describes the general idea of an assistive media​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!