Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Overview The objective of this assignment is to read in a list of playing) cards from standard input and output a frequency histogram of the

image text in transcribed

Overview The objective of this assignment is to read in a list of playing) cards from standard input and output a frequency histogram of the playing cards read in. Task Recall some of the Week 03 Lecture Files, e.g., p7.cxx, r1.cxx, r2.cxx, and r3.cxx where: The p7 program was capable of reading in and writing out (playing) cards, i.e., struct card. 1 to r3 was capable constructing a frequency histogram. This assignment's task is to read in card structs from standard input and place such in to a frequency histogram. Input is to occur until EOF (end-of-file) or an input error occurs. After reading in all input, for each entry in the frequency histogram's map, output the following (always on its own line): occurs time(s) where is the card and is the number of times it occurs in the histogram. (The output for card is the same as how p7.cxx's card type is output.) Tips Do look at p7, r1, r2, and r3 to write the code for this assignment. Copy the relevant bits you need in to your code. o NOTE: if you take p7.cxx and delete all lines starting at "struct cards" (i.e., line 85) to the end, then you will only need to write main to do this assignment. :-) To output the histogram, use iterators to iterate through the map (or a range for loop). NOTE: Use prefix ++ instead of postfix ++. Why? Prefix ++ and -- are more efficient --only use the postfix forms when they are absolutely needed. Each element in the map is a std::pair and one can access the key via first or ->first and Value via second or -> second. . Most of the code for this assignment is from the p7.cxx --but with the code handling cards removed and the code inside main() removed. Essentially this assignment is writing code in main() to compute a frequency histogram of cards since the rest of the code has been provided. Sample Program Input The program input will be a series of zero or more cards. (Read the input until EoF or an error.) For example, sample input might be placed in a file called input.dat, e.g., 1. 2. 3. $ cat input.dat 10D3S4H9C10D8H2D12510D6H2D4H $ Sample Program Run The program output for the above input.dat file is: 1 2. 3. $ g++-10.2.0 -Wall - Wextra Werror a3.cxx $ ./a.out occurs time(s) where is the card and is the number of times it occurs in the histogram. (The output for card is the same as how p7.cxx's card type is output.) Tips Do look at p7, r1, r2, and r3 to write the code for this assignment. Copy the relevant bits you need in to your code. o NOTE: if you take p7.cxx and delete all lines starting at "struct cards" (i.e., line 85) to the end, then you will only need to write main to do this assignment. :-) To output the histogram, use iterators to iterate through the map (or a range for loop). NOTE: Use prefix ++ instead of postfix ++. Why? Prefix ++ and -- are more efficient --only use the postfix forms when they are absolutely needed. Each element in the map is a std::pair and one can access the key via first or ->first and Value via second or -> second. . Most of the code for this assignment is from the p7.cxx --but with the code handling cards removed and the code inside main() removed. Essentially this assignment is writing code in main() to compute a frequency histogram of cards since the rest of the code has been provided. Sample Program Input The program input will be a series of zero or more cards. (Read the input until EoF or an error.) For example, sample input might be placed in a file called input.dat, e.g., 1. 2. 3. $ cat input.dat 10D3S4H9C10D8H2D12510D6H2D4H $ Sample Program Run The program output for the above input.dat file is: 1 2. 3. $ g++-10.2.0 -Wall - Wextra Werror a3.cxx $ ./a.out

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions