Question: General Instructions: You are to utilize the template, source code file for an assigned Project solution, Client.cpp, provided on the Canvas website for this course.
General Instructions: You are to utilize the template, source code file for an assigned Project solution, Client.cpp, provided on the Canvas website for this course. You must provide comments in the code you provide and complete the required sections of the file comment header block and the method comment header block preceding method main. You are to create a program that requires the User to provide the answer for the sum of two, 3-digit at most, values presented to the User. The program will indicate if the answer is correct, and if not, provide the correct answer. In addition, the User is allowed to play the game again. Specific Instructions: 1. Provide a description of the game to the User. 2. You must use the C random number generator to create the two addend values provided to the User. You must seed the generator, just once, with the current time. 3. The addend values must be in the inclusive range: 10 130. 4. You are to provide a separate method that returns a random value given the min and max method argument values. Name the method randomValue. Copy the comment header block for main, pasting it preceding the method and modify the required sections as needed. 5. Use a loop construct suitable for being executed at least once to prompt the User if the game is to be repeated. If the answer is the character y, the game is repeated until any answer other than y is entered.
Sample Run: CS-300 Project #1: Arithmetic Game This program will present a 2-addend arithmetic problem to the User. The answer will be solicited and the status of the guess provided. The User is then allowed to play the game again. 68 + 50 ---- Your answer: 118 Correct! Play the game again ('y'): y 93 + 24 ---- Your answer: 119 Sorry, the answer is: 117 Play the game again ('y'): n Press only the 'Enter' key to exit program:
This is Client.cpp code
/****************************************************************************** * Bellevue Class: CS-300 * Instructor: Robert Main * Term: Winter 2023 * * Textbook: Data Abstraction & Problem Solving with C++ * Edition: 7th * Authors: Frank M. Carrano and Timothy M. Henry * * Assigned Project Solution * Project: X * * Solution/Project Name: * File Name: Client.cpp * * This file defines the entry point method, main(), for a C++ Console * application. When the executable file is selected for execution, the OS * will transfer execution to the first line of code in method main(). Other * methods called from main() may be defined here as well. * * Revision Date Release Comment * -------- ---------- ------------------------------------------------------- * 1.0 MM/DD/YYYY Initial Release * * Program Inputs * -------------- * Device Description * -------- ------------------------------------------------------------------- * Keyboard * * Program Outputs * --------------- * Device Description * -------- ------------------------------------------------------------------- * Monitor * * File Methods * ------------ * Name Description * ------------ --------------------------------------------------------------- * main Program entry point method * ******************************************************************************* */ // External Definition files // 1. C++ Library files #include
using namespace std; // Announces to the compiler that members of the // namespace "std" are utilized in this program
// Method Prototypes // ----------------- // None
/****************************************************************************** * Method: main() * * Method Description * ------------------ * This is the entry function to the Client, Console program * *** Provide your description of the program here *** * * * Preconditions * ------------- * *** Must be completed, state "None" if there are no preconditions *** * * Method Arguments * ---------------- * Type name Description * ------ -------- ----------------------------------------------------------- * *** If no arguments, replace 2 lines with: No arguments required *** * * Return Value * ------------ * Type Description * -------- ------------------------------------------------------------------- * int Program execution status: 0 - No errors * *** If "void", state: The method returns no value *** * * Invoked File Methods * -------------------- * Name Description * ---------- ----------------------------------------------------------------- * *** If no additional file methods, replace 2 lines with: None *** * ******************************************************************************* */ int main() { // Constant "const" Value Declarations const int NO_ERRORS = 0; // Program Execution Status: No errors
// Initialized Variable Declarations int programStatus = NO_ERRORS; // Assume no program execution errors // Uninitialized Variable Declarations
// Insert your code here *** remove this line ***
// This prevents the Visual Studio Console Window from closing during // debug mode. // This next statement purges any characters, if any, remaining in the // Console input buffer, BEFORE "cin.get()" looks for the "new line" // character. cin.ignore(cin.rdbuf()->in_avail(), ' '); cout << " Press only the 'Enter' key to exit program: "; cin.get();
// Inform the OS of the execution status of the program return programStatus;
} // End Method: main()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
