Write a program that initially prompts the user for a file

Assignment Help C/C++ Programming
Reference no: EM132101194

Please Write C++ PROGRAM :

That will write a program that initially prompts the user for a file name. If the file is not found, an error message is output, and the program terminates. Otherwise, the program prints each token in the file, and the number of times it appeared, in a well formatted manner. To accomplish all this, do the following:

- Open the file - the user must be prompted and a file name input. DO NOT hardcode a file name.

- Read the words in the file, placing them in an array of struct with capacity I 00, where each struct has a string (the word) and an int (number of occurrences)

- Sort the array, eliminating duplicates

- Report the results

- You must write appropriate functions for each task. At minimum, you must write a function for each of the following:

• Open the file:

o Pass in an ifstream (must be a reference argument [what type of parameter is it?]). The function prompts the user and, if the file is found, it returns true and the ifstream will be a handle for that text file. Otherwise the function returns false , and the argument is assumed to be undefined.

• Populate the array of struct with the words in the file:

o Pass in two reference arguments, the ifstrcam, and the l 00 element array of word/count structs. When the function completes, the array will hold the words in the file.

• Output results:

o Pass in the variables that bold the file name and the word/count array. Use this data to

produce the desired ouput, which should be appropriately fonnatted.

• Sort an array of structs (the name/int pairs), eliminating duplicates:

o Pass in the array of struct, and the number of elements in the array. The function sorts the array, in ascending order of words, eliminating duplicates and tabulating counts as it goes. It definitely uses other functions for specific purposes, e.g. identifying duplicate tokens and swapping structs.

• Increment the counter member of a struct that holds a word and its multiplicity:

o Pass in a single struct; it will be an import/export parameter. Simply increment its counter member.

Notes:

» A word, or token, is whatever is read using the >> operator. A word followed by a period is distinct from the same word without the period. Words are also case sensitive, i.e. heLLo is not equal to Hello.

» When a word is placed into the array of struct, its counter is initially 1.

» When the array reaches capacity:

If there aren't 100 unique words already in the array, run the sort function to eliminate duplicates.

If the file has 100 unique words, then after the tooth unique word is added to the array, only repeats will be tabulated. New tokens will be discarded.

» While several functions are required, other functions should be written as well.

No function..should handle multiple tasks on its own. Non-modular designs will be penalized.

» In sorting, if the word being placed is a duplicate, the already placed word must have its counter incremented, and the duplicate must be removed from the array.

- The program must be well written, properly indented, and commented

Reference no: EM132101194

Questions Cloud

How do you think so many social media platforms : How do you think so many social media platforms/messages are able to get away with deceptive advertisement? What are some examples??
Write a program that will use a recursive binary search : Write a program that will use a recursive binary search to locate an integer in a sorted array. The integer values will be provided in a file named dataarray.
Determine the highest sales in the report : Write a function that sorts the arrays sales data in ascending order. You may not use selection sort. Bubble sort example.
Write a program to calculate how many squares are required : There is an old story that the emperor wanted to thank the inventor of the game of chess and asked the inventor to name his reward.
Write a program that initially prompts the user for a file : Write a program that initially prompts the user for a file name. If the file is not found, an error message is output, and the program terminates.
Write a program calendar c that takes two inputs : Write a program calendar.c that takes two inputs: the start day of a month [Sunday is 0, Monday is 1,....., Saturday is 6] and the number of days in a month.
Create an array that holds random integers : Create an array that holds 1000 random integers between 1-1000. Please write a short paragraph, bullet points.
Prove the logical equivalence of conditional statement : Prove the logical equivalence of conditional statement and contrapositive of two propositional variables using truth table.
Define and integer variable named employeescount : Defines a structure called Employee that contains a character member called id that can hold an id that is up to 9 characters long and a float member.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd