[SOLVED] C++ game Lab 6 Array Searching Game

$25

File Name: C++_game_ Lab_6__Array_Searching_Game.zip
File Size: 348.54 KB

5/5 - (1 vote)

Lab 6 Array Searching Game

Please write a C++ application program that will accept a list of integers (up to 20) from the user into an array, and then show those numbers, the largest integer, the smallest integer, the sum of all integers, and the average of all integers.Then, your program allows the user to search for a number in the list.If the number from the user is in the list, please show its index position in the list, otherwise please say the number is not found.Please use index position starting from 1, instead of 0, to make your messages more user-friendly.Please stop the search game if the user enters -1 as a number to search.Then, you continue to accept another list of integers (up to 20) from the user.Please stop your program with a thank-you message if the user enters zero as the number of integers to play.Please see the sample test below to design your application program properly.This program is like a game of number searching for users to play.This is an application of a single-dimensional array.
You must not sort the numbers in your array.Therefore, you must use sequential search to find the number in your array.You must not use binary search because your array is not sorted.

The following is a sample test, which must be your test case #1.You must also do test case #2 and test case #3 with different set of data.Each test case must accept at least two lists of integers from the user, and must search at least 3 numbers for each list.

Welcome to the C++ Game World of Dr. Simon Lin!
Please enter how many integers you would like to play (up to 20, 0 to stop) > 5
Please enter 5 integers in any order> 2 5 3 4 1
Your 5 integers are:2 5 3 4 1
The largest integer is 5, the smallest integer is 1, the sum of all integers is 15, & the average is 3
Please enter a number to search (-1 to end the search)> 4
The number 4 is found at the position 4
Please enter a number to search (-1 to end the search)> 44
The number 44 is not found.
Please enter a number to search (-1 to end the search)> 1
The number 1 is found at the position 5
Please enter a number to search (-1 to end the search)> -1
Please enter how many integers you would like to play (up to 20, 0 to stop) > 6
Please enter 6 integers in any order> 9 20 5 3 34 18
Your 6 integers in ascending order are: 9 20 5 3 34 18
The largest integer is 34, the smallest integer is 3, the sum of all integers is 89, & the average is 14
Please enter a number to search (-1 to end the search)> 34
The number 34 is found at the position 5
Please enter a number to search (-1 to end the search)> 19
The number 19 is not found.
Please enter a number to search (-1 to end the search)> 3
The number 3 is found at the position 4
Please enter a number to search (-1 to end the search)> 20
The number 20 is found at the position 2
Please enter a number to search (-1 to end the search)> -1
Please enter how many integers you would like to play (up to 20, 0 to stop) > -1
Please enter how many integers you would like to play (up to 20, 0 to stop) > -4
Please enter how many integers you would like to play (up to 20, 0 to stop) > -99
Please enter how many integers you would like to play (up to 20, 0 to stop) > 0
Thank you for playing this SUPER game designed by Dr. Simon Lin!
======================================================================.
For structured programming and design, it would be better to write the following functions to complete this lab assignment:
int max( int A[20], int N ) // return max of first N integers in array A
{ ; }
int min( int A[20], int N) // return min of first N integers in array A
{ ; }
int sum( int A[20], int N) // return sum of first N integers in array A
{ ; }
int avg( int A[20], int N) // return average of first N integers in array A
{ ; }
void show(int A[20], int N) // print the first N integers in array A
{ ; }
int search( int A[20], int N, int K) // return position of K found in array A
{ ; } // return -1 if K is not found in array A

int A[20] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
int N ; // number of integers to be processed per users request
int K ; // key number to be search in A[20] array per users request
int pos ; // position for the number K found in A[20] array, -1 if not found
======================================================================.
How to submit your Lab or Project Assignment (PA)?
(1) Each program must be well documented with block comments and proper line comments.
The beginning of each program must have a block comment to show its author, date, and purpose.
The following is an example of block comments:
// Author:You must use your full name here!
// Date: You must put todays date here!
// Purpose: . . . You must show the purpose of this program here!
(2) You must submit to Canvas the following 2 items as attachments:
(a) Your source program (for example, CS243-Lab6.cpp ), and
(b) Your WORD document (for example, CS243-Lab6-report .docx ) containing the listing of
your C++ program, and the output of 3 test runs of your program (as shown below).
=========================================================================.
// Please delete everything above this line to make this your Word document to be submitted.
Lab 6 Report My Name: ________________
The following is my C++ source program:
// Please copy your source program into here from your Visual Studio window.The code must be colored.
// You must not copy source program from your Lab6.cpp file since the code over there is not colored at all.

The following is the output of3 test runs of my program:
// One way to copy the console output is press Ctrl+Alt+PrtScn.To paste it is to press Ctrl+v.
// Please copy your console output and paste into here:

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] C++ game Lab 6 Array Searching Game
$25