Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Sultan Qaboos University College of Science COMP2102: Problem Solving and Programming, Spring 2018 Homework Assignmen 1 Due Date: 28 February 2018 t of Computer Write

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Sultan Qaboos University College of Science COMP2102: Problem Solving and Programming, Spring 2018 Homework Assignmen 1 Due Date: 28 February 2018 t of Computer Write a program for playing a name guessing game. The program asks the user to select a name category (female or male), selects randomly a name from a list of names, and then asks the user to guess one letter of the randomly selected name or to guess the entire randomly selected name. The program starts by reading into two separate arrays a list of female names (from a data file female.txt) and a list of male names (from a data file male.txt). The program then selects randomly one name from one of the two lists based on the user's selected name category (female or male) as indicated in the provided sample run. You need to create sample data files to test your solution. If the user makes three invalid guessing attempts (for a letter or for the entire word). terminate the current game and display the main menu to select a name category for a new game. Study carefully the sample run of the program to understand the requirements. Make your program as informative to the user as possible as in the sample run. The program should accept both lowercase and upper case letters input from the user. Give appropriate messages for invalid user input data or if the data files cannot be opened. In this assignment you are requested to submit two parts: Partl: Problem Solving: Submit a PDF document containing your solution analysis in terms of the Program Development Process steps discussed in Chapter 2 ubi ource.cpp file of your implementation. Name your submitted files as HW1_XXXXXX.pdf for parti and HW1 XXXXXX.cpp for part2 where XXXXXX is your university ID. Upload both partl and part2 to Moodle by the due date. Your program should include at least the functions listed below. Include additional functions to further modularize your solution. The function main) should act as a director implementing the basic program logic and coordinating the program flow int DiplayMenu Displays the menu and returns the user selection Reads two lists of names (female and male) from the two data files and stores them into two separate arrays and returns (via parameters) the sizes of the two lists. It uses the ReadFilefunction. int ReadFile(ifstream& --); Reads one list of names from the specified file into the specified array and returns the list size. void PlayD Receives the selected name category array and its size and implements the game logic as shown in the sample run. It uses the function GetRandomName(...) Selects and returns a random name from a specified array

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

Example. Evaluate 5n+7 lim 7-00 3n-5

Answered: 1 week ago

Question

What is the R Square value?

Answered: 1 week ago

Question

Which field has the highest average (mean)?

Answered: 1 week ago

Question

What is the highest outlier from the in-person transactions?

Answered: 1 week ago