Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Spinach Radishes Broccoli Peas Cranberries Broccoli Potatoes Cucumbers Radishes Cranberries Peaches Zucchini Potatoes Cranberries Cantaloupe Beets Cauliflower Cranberries Peas Zucchini Peas Onions Potatoes Cauliflower Spinach

image text in transcribedimage text in transcribed

Spinach Radishes Broccoli Peas Cranberries Broccoli Potatoes Cucumbers Radishes Cranberries Peaches Zucchini Potatoes Cranberries Cantaloupe Beets Cauliflower Cranberries Peas Zucchini Peas Onions Potatoes Cauliflower Spinach Radishes Onions Zucchini Cranberries Peaches Yams Zucchini Apples Cucumbers Broccoli Cranberries Beets Peas Cauliflower Potatoes Cauliflower Celery Cranberries Limes Cranberries Broccoli Spinach Broccoli Garlic Cauliflower Pumpkins Celery Peas Potatoes Yams Zucchini Cranberries Cantaloupe Zucchini Pumpkins Cauliflower Yams Pears Peaches Apples Zucchini Cranberries Zucchini Garlic Broccoli Garlic Onions Spinach Cucumbers Cucumbers Garlic Spinach Peaches Cucumbers Broccoli Zucchini Peas Celery Cucumbers Celery Yams Garlic Cucumbers Peas Beets Yams Peas Apples Peaches Garlic Celery Garlic Cucumbers Garlic Apples Celery Zucchini Cucumbers Onions

NEED IT TO SHOW ALL THE FREQUENCY OF THESE ITEMS WITH THIS CODE WITH SCREEN SHOTS, I CANNOT GET MY TXT.FILE TO UPLOAD INTO THE GDB ONLINE COMPLIER

#include #include #include

using namespace std;

class Grocer { private: map items;

public: void readFile (string fileName) { ifstream inputFile; inputFile.open (fileName);

if (inputFile.is_open ()) { string item; while (inputFile >> item) { items[item]++; } inputFile.close (); } else { cout

void writeFile (string fileName) { ofstream outputFile; outputFile.open (fileName);

if (outputFile.is_open ()) { for (auto const &item:items) { outputFile

int findItem (string item) { if (items.count (item) > 0) { return items[item]; } else { return 0; } }

void printFrequency () { for (auto const &item:items) { cout

void printHistogram () { for (auto const &item:items) { cout

int main () { Grocer grocer; grocer.readFile ("CS210_Project_Three_Input_File.txt"); grocer.writeFile ("frequency.dat");

int choice; string item; do { cout > choice;

switch (choice) { case 1: cout > item; cout

return 0; }

As you work, check your code's syntax to ensure that your code will run. Note that when you compile your code, you will be able to tell if this is successful overall because it will produce an error message for any issues regarding syntax. Some common syntax errors are missing a semicolon, calling a function that does not exist, not closing an open bracket, or using double quotes and not closing them in a string, among others. The program that the Corner Grocer is asking you to create should address the following functional requirements: Menu Option One: 1. Prompt a user to input the item, or word, they wish to look for. 2. Return a numeric value for the frequency of the specific word. Menu Option Two: 1. Print the list with numbers that represent the frequency of all items purchased. The screen output should include every item (represented by a word) paired with the number of times that item appears in the input file, CS210_Project_Three_Input_File.txt. For example, the file might read as follows: Potatoes 4 Pumpkins 5 Onions 3 Menu Option Three: 1. Print the same frequency information for all the items in the form of a histogram. 2. Then print the name, followed by asterisks or another special character to represent the numeric amount. The number of asterisks should equal the frequency read from the CS210_Project_Three_Input_File.txt file. For example, if the file includes 4 potatoes, 5 pumpkins, and 3 onions, then your text-based histogram may appear as represented below. However, you can alter the appearance or color of the histogram in any way you choose: 1. Exit the program. Data File Creation: Create a data file, with the naming convention frequency.dat, for backing up your accumulated data. The frequency.dat file should include every item (represented by a word) paired with the number of times that item appears in the input file. This output file is created in the beginning of the program without user intervention and is for backup purposes. For assistance with writing files, see sections 7.1, "File Input," and 7.3, "File Output," in zyBooks. Documentation: Describe your code's design and functionality. Include screenshots to support your description. As you complete this work, your manager at Chada Tech is interested to see your thought process regarding how you use C++. Implementation Guidelines Note: We recommend using the Virtual Lab to complete this assignment. However, if you choose to complete this assignment locally, please use the version of Microsoft Visual Studio outlined in the syllabus. The SNHU IT Service Desk will be unable to support concerns related to local assignments. - For this assignment, your implementation plan must include at least one class with public and private sections. For assistance with classes, see sections 6.2, "Using a Class," and 6.3, "Defining a Class," in zyBooks. - For this assignment, we recommend using Maps (section 11.4 in zyBooks) for implementation. Maps do require precise coding syntax. However, you can choose a different implementation option

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 Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions