Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

home / study / engineering / computer science / computer science questions and answers / *******************i need the functions in the cpp to be in

home / study / engineering / computer science / computer science questions and answers / *******************i need the functions in the cpp to be in the format below, taking all the ...

Question: *******************I NEED THE FUNCTIONS IN THE CPP TO BE IN THE FORMAT BELOW, TAKING ALL THE SPEC...

*******************I NEED THE FUNCTIONS IN THE CPP TO BE IN THE FORMAT BELOW, TAKING ALL THE SPECIFIED PARAMETERS/ARGUMENTS. ALL ANSWERS WITHOUT THE FORMAT BELOW WILL BE CONSIDERED INCORRECT AND I WILL DOWNVOTE. ******************************

void readResponses(ifstream &infile, string responses[ ], string categories[ ], int &size );

void playMagicEightBall(string responses [ ], string categories [ ], int size );

void sortByResponses(string responses [ ], string categories[ ] , int size);

void sortByCategories(string responses [ ], string categories [ ], int size );

void writeToFile(ofstream &, string responses [ ], string categories [ ], int size );

*******************I NEED THE FUNCTIONS IN THE CPP TO BE IN THE FORMAT ABOVE, TAKING ALL THE SPECIFIED PARAMETERS/ARGUMENTS. ALL ANSWERS WITHOUT THE FORMAT ABOVE WILL BE CONSIDERED INCORRECT AND I WILL DOWNVOTE. ******************************

CSCI 1410 PA 2 Outline (10 points)

Read the problem set for PA 2 below. Create an outline in plain English. Place this outline in either //line comments or /*block*/ comments. For the PA2, you will place the C++ code under the corresponding lines of code. Place these comments in a file called main.cpp. Also provide a functions.h which gives the function prototypes and a file called functions.cpp which gives a brief description of each function and an outline in plain English (in comments) for the algorithm to complete that function. When complete zip those 3 files (and ONLY those three files) into a file formatted like lastnameFirstinitialPA2.zip (e.g. lastnamePA2.zip)

Example:

/*NAME: first lastname

CLASS: CSCI1410

DESCRIPTION:

STATUS: Not running, just an outline

CSCI 1410 PA 2 Magic Eight Ball (35 points)

Have you ever wanted to predict the future? Well the Magic Eight Ball does just that. The original game was a softball sized 8-ball. You would ask a question, shake it up and look at the result. There are 20 responses10 positive, 5 negative, and 5 are vague. For this project, we want to recreate this, but give the ability to read in a set of responses, and add additional responses, and print out all of the responses in alphabetical order. Of course, we have to give seemingly accurate responses, which we will do by giving a random response.

Program Details:

You should have a menu with five lettered options. You should accept both capital and lower case letters in your menu options. The menu should do the task, then return to the menu (except in the case of exit). Any incorrect responses should get an error message, followed by a reprint of the menu.

Read responses from a file

Play Magic Eight Ball

Sort by responses

Sort by and categories

Write responses to a file

Exit

Each menu item must be implemented using a function or sets of functions with appropriate input parameters and return values. Functions will have a prototype in a file called functions.h and defined in a file called functions.cpp.

Implementation Detail 1: Remember you will need to #include functions.h into both your main.cpp and functions.cpp but do not include .cpp files

Implementation Detail 2: You should have an duplicate guard in your functions.h like: #ifndef FUNCTIONS_H #define FUNCTIONS_H void readResponses(ifstream &infile, string responses[ ], string categories[ ], int &size );

void playMagicEightBall(string responses [ ], string categories [ ], int size );

void sortByResponses(string responses [ ], string categories[ ] , int size);

void sortByCategories(string responses [ ], string categories [ ], int size );

void writeToFile(ofstream &, string responses [ ], string categories [ ], int size );

#endif

Implementation Detail 3: .txt files. In most IDEs, you need to make sure all of your files are included in the project. For VS and csegrid, make sure all files are in the same directory. For XCode, you will need to place them in the same directory, then go to Product->Scheme->Edit Scheme and Use custom working directory where your .cpp and .txt files are located. For the csegrid run your program with g++ -o pa2.o main.cpp functions.cpp. Then run with ./pa2.o. For CLion, you need to place the .cpp and .h files in the project directory, and the .txt file in the cmake-debug folder

Implementation Detail 4: You must use two arrays of the same size. One for the response and one for the category. Position zero of the response array will correspond to position zero of the category array (so when using both the response and category, you will have to use two addresses). You may not use vectors structs or classes.

Implementation Detail 5: You can not have any global variables. So you will need to declare variables in main, then pass them (as appropriate) to your functions. Remember that there is no built in size for arrays, so you will have to pass the size (and MAXSIZE when trying to add to an array)

Implementation Detail 6: You will need to choose a random response. See the example at http://www.cplusplus.com/reference/cstdlib/rand/

Note: You need some additional #include statements. You will use srand ONLY once in main, then use rand() with the modulus operator (%) to get a number between 0 and size -1

Extra Credit: If you have ALL of the functionality listed above, you can get up to 5 points extra credit (So a 45/40) if you implement a Delete Answers function and add as another menu item. Since you cant delete a cell in a static array, instead of an actual delete you would need to shift everything one character to the left then decrease the size by one (so your for loops should go zero to size, not zero to MAXSIZE. ) For add, it is just like reading from a file except you will read from cin (using getlines). Dont forget to ensure the size is passed by reference, so when you add or delete and change the size, you are changing the size in main. Make sure to list that in your status if you want the extra credit.

Implementation Detail 6: Responses are as follows:

It is certain

positive

It is decidedly so

positive

Without a doubt

positive

Yes definitely

positive

You may rely on it

positive

As I see it, yes

positive

Most likely

positive

Outlook good

positive

Yes

positive

Signs point to yes

positive

Reply hazy try again

vague

Ask again later

vague

Better not tell you now

vague

Cannot predict now

vague

Concentrate and ask again

vague

Don't count on it

negative

My reply is no

negative

My sources say no

negative

Outlook not so good

negative

Very doubtful

negative

IDE and Deliverables:

You may use any individual development environment (IDE) that you choose (VS, XCode, csegrid, Clion), Deliver one file in the format lastnameFirstinitialPA2.zip (containing a main.cpp, functions.h and functions.cpp) to canvas by the due date. Make sure to update the status in the comments to include what IDE you developed it in and whether it fully runs as directed, or has issues/error or only partially works.

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

Building The Data Warehouse

Authors: W. H. Inmon

4th Edition

0764599445, 978-0764599446

Students also viewed these Databases questions

Question

2. I try to be as logical as possible

Answered: 1 week ago

Question

Is SHRD compatible with individual career aspirations

Answered: 1 week ago