Question

c++ please Create a map that works like a dictionary with words and their definitions. In...

c++ please

Create a map that works like a dictionary with words and their definitions. In this case, it will be a set of acronyms, such as HTML, CSS, I/O, etc. Then write a quiz program that prompts the user with an acronym to see if they know what it stands for. Create at least five acronyms and have your program quiz the user for all of them. Have your program display "Right!" if the user is correct, and "No, the answer is....." if the user is wrong.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <iterator> // this header is used to get the iterator for our map
#include <map> // for obtaining map functions
#include<string>
  
using namespace std;
  
int main()
{
  
// empty string map container
map<string, string> quiz;
string answer;
  
// insert elements in random order
quiz.insert(pair<string, string>("JRE","Java Runtime Engine"));
quiz.insert(pair<string, string>("DBMS", "Data Base Management System"));
quiz.insert(pair<string, string>("FORTRAN", "FORmula TRANslation"));
   quiz.insert(pair<string, string>("IDE", "Integrated Development Environment"));
   quiz.insert(pair<string, string>("ASCII", "American Standard Code for Information Interchange"));
  
// Take map quiz

//create map iterator

map<string, string>::iterator itr;
cout << "\nThe quiz begins : \n";

// begin the loop for the map using iterator
for (itr = quiz.begin(); itr != quiz.end(); ++itr) {

cout << '\t' << itr->first<<"\n"<<"Enter the answer: "; // ask first question (need not be in the // order of created map
cin>>answer; // take input
if(answer==itr->second) // check if input matches the value in the map
cout<<"\n Right!"; // if correct print RIGHT!
cout<<"\n No, the answer is "<<itr->second<<"\n"; // else NO, ....

}
}

Add a comment
Know the answer?
Add Answer to:
c++ please Create a map that works like a dictionary with words and their definitions. In...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a program using Python, following the steps below: 1) Collect the Users name, and store...

    Create a program using Python, following the steps below: 1) Collect the Users name, and store that name. 2) Welcome the user, and ask if that user would like to take the Capitals quiz. 3) Create a dictionary of US states as keys and the state capitals that correspond with your list, as the values (Choose 12 of your favorite states). 4) Then have the program quiz the user, randomly asking for the capital of each of the states in...

  • write a C program to make the dictionary USING LINKED LISTS and STORE DATA in File HANDLING..... you have to create functions 1. insert 2. delete 3. search(if we search with any letter then the words...

    write a C program to make the dictionary USING LINKED LISTS and STORE DATA in File HANDLING..... you have to create functions 1. insert 2. delete 3. search(if we search with any letter then the words with same first letter have been shown) 4. display 6. exit Appearance should be like proper dictionary.

  • PLEASE DO IN JAVA You can use any source for the dictionary or just a few...

    PLEASE DO IN JAVA You can use any source for the dictionary or just a few words are fine! description The purpose of this assignment is to practice with ArrayLists (and hopefully, you'll have some fun). As far as the user knows, play is exactly as it would be for a normal game of hangman, but behind the scenes, the computer cheats by delaying settling on a mystery word for as long as possible, which forces the user to use...

  • Can someone plz help me??? I would like a website that has to do with guitars...

    Can someone plz help me??? I would like a website that has to do with guitars or something to do with music, someone asked me what kind of website I would like to have and that would be awesome. The attributes to be included, are below. I need a small website that to where I need to interlink a CSS file into the HTML file. I don't know to save the files to have to be able to run with...

  • IN C# Objectives: Create an application that uses a dictionary collection to store information ...

    IN C# Objectives: Create an application that uses a dictionary collection to store information about an object. Understanding of abstract classes and how to use them Utilize override with an abstract class Understanding of Interfaces and how to use them Implement an Interface to create a “contract” between classes. Compare and contrast inheritance and interfaces. Instructions: Interface: Create an interface called ITrainable which contains the following: Dictionary<string, string> Behaviors{ get; set; } string Perform(String signal); string Train(String signal, string behavior);...

  • Java program. Please make it user friendly output; Create a software, a program that will tell...

    Java program. Please make it user friendly output; Create a software, a program that will tell input to build a computer, the computer can be a desktop or laptop. The desktop variables are case size, processor brand and speed, hard drive size, RAM size, display monitor size, video output e.g. HDMI, also let the user have an option of upgraded software if needed. When it comes to laptop goes for the same thing, like CPU, RAM size, capacity of hard...

  • C++ program: can you help create a autocorrect code using the cpp code provided and the...

    C++ program: can you help create a autocorrect code using the cpp code provided and the words below using pairs, vectors and unordered map: Objectives To practice using C++ std::pair, std::vector, and std::unordered_map To tie together what we've learned into the context of a real-world application used by millions of people every day Instructions For Full Credit You're given a short list of words in known_words_short.txt that contains a handful of very different words. Assume this short list of words...

  • Please design, write the code and create the requisite submission files in C++ for the following...

    Please design, write the code and create the requisite submission files in C++ for the following problem: A menu-driven program that offers the user 5 options as follows: Menu: 1. Display array 2. Add up all elements in the array and display that number. 3. Add 1 to each element in the array. 4. Swap the values in row one with the values in row three. 5. Exit In main(), declare and initialize a 2-dimensional array that contains 5 x...

  • We would like to create an Assembly program whose executable is called division.exe and that behaves...

    We would like to create an Assembly program whose executable is called division.exe and that behaves as follows:  It requests a positive number from the user.  Once it gets the user input, it divides the number by 5 without using the DIV instruction in assembly  It outputs the Quotient and the Remainder As an example, if a user runs the assembly program division.exe and provides a value 34 as an input, the display should show the following:...

  • Please do the following project in C++ programming language. You can use a bag to create...

    Please do the following project in C++ programming language. You can use a bag to create a spell checker. The bag serves as a dictionary and contains a collection of correctly of correctly spelled workds. To see whether a word is spelled correctly, you see whether it is contained in the dictionary. Use this scheme to create a spell checker for the words in an external file. To simplify your task, restrict your dictionary to a manageable size. The dictionary...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT