Question
Need help with programming, C++ Have you ever wanted to predict the future? Well the Magic Eight Ball does just that. The original game was
Need help with programming, C++
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. These responses are given in the file responses.txt and listed in the last page. 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. a. Read responses from a file b. Play Magic Eight Ball c. Print out responses and categories alphabetically d. Write responses to a file e. Exit Each menu item must be implemented using a function or sets of functions with appropriate input parameters and return values. Functions will have prototypes in a file called functions.h and defined in a file called functions.cpp. Also, you will have a struct for the response and whether it is positive, negative, or vague. That struct will also be in the functions.h file.
Here is a general explanation of what each option should do: a. Read responses from a file: This will read the responses and their category from the file responses.txt into an array. b. Play Magic Eight ball: User will ask a question, and a random response with a category is given from the array. c. Print out responses and categories alphabetically: Need to sort the responses in the array and print them. d. Write responses to a file: Write the array of responses with the categories (on separate lines) to a new file. You can name that file responsesOutput.txt.
Implementation Detail 1: Remember you will need to #include functions.h into both your main.cpp and functions.cpp. Implementation Detail 2: You should have a duplicate guard in your functions.h like: #ifndef FUNCTIONS_H #define FUNCTIONS_H //your code here #endif
Responses.txt
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started