Explain the need for arrays in a program

Assignment Help Basic Computer Science
Reference no: EM13919815

A. Lab # CIS CIS170C-A5
B. Lab 5 of 7: Arrays and Strings
C. Lab Overview - Scenario/Summary

You will code, build, and execute two programs requiring arrays and strings.
First program (Video Game Player Program): Determine the average score for a group of players and then determine who scored below average.

Second program (Pig Latin): Convert words in a phrase to pig latin.
Learning outcomes:

1. Be able to explain the need for arrays in a program.
2. Be able to determine the appropriate array data type to use in a given program.
3. Be able to write a program that implements arrays.
4. Be able to explain the way memory is allocated for arrays in a program.
5. Be able to explain the fact that arrays are objects in C++.

6. Be able to write a program that implements strings

D. Deliverables
Section Deliverable Points
Part A Step 5: Program Listing and Output 20
Part B Step 5: Program Listing and Output 25

E. Lab Steps

Preparation:

If you are using the Citrix remote lab, follow the login instructions located on the iLab tab in Course Home.
Locate the Visual Studio 2010 icon and launch the application.

Lab:

Part A: Video Game Player Program
Step 1: Requirements
Write a program to do the following:
In main, declare a PlayerName Array and a Score Array. Declare the size of the arrays to be 100.
In the InputData function, input the player name and score into the arrays for an unknown number of players up to 100.
In the DisplayPlayerData function, display the name and score of each player.
In the CalculateAverageScore function, calculate the average score and return it by value.

In the DisplayBelowAverage function, display the name and score for any player who scored below the average. Do not use global variables.

Output from Program:

Enter Player Name (Q to quit): Bob
Enter score for Bob: 3245
Enter Player Name (Q to quit): Sue
Enter score for Sue: 1098
Enter Player Name (Q to quit): Dave
Enter score for Dave: 8219
Enter Player Name (Q to quit): Pat
Enter score for Pat: 3217
Enter Player Name (Q to quit): Q
Name Score
Bob 3245
Sue 1098
Dave 8219
Pat 3217
Average Score: 3944.75
Players who scored below average
Name Score
Bob 3245
Sue 1098
Pat 3217
Press any key to continue . . .

Step 2: Processing Logic
Using the pseudocode below, write the code that will meet the requirements.
Main Function
Declare the player name and score arrays, number of players, and average score.
Call the InputData function
Call the DisplayPlayerData function
Call the CalculateAverageScore function and assign the returned value in average score
Call the DisplayBelowAverage function
InputData function
While the number of players is less than the length of the array
Prompt for the player's name
If the user entered Q, break out of the loop
Prompt the user for the player's score
Add 1 to the number of players
End-While
DisplayPlayerData function
Display the name and score of each player
CalculateAverageScore function
Add up the scores and divide by the number of scores to calculate the average score
Display the average score
Return the average score to main
DisplayBelowAverage function
Display the names and scores of all players who scored below the average score

Step 3: Create a New Project
Create a new project and name it LAB5A. Write your code using the Processing Logic in Part A, Step 2. Make sure you save your program.

Step 4: Compile and Execute
a) Compile your program. Eliminate all syntax errors.
b) Build your program and verify the results of the program. Make corrections to the program logic if necessary until the results of the program execution are what you expect.

Step 5: Print Screen Shots and Program
1. Capture a screen print of your output. (Do a PRINT SCREEN and paste into an MS Word document.)
2. Copy your code and paste it into the same MS Word document that contains the screen print of your output.
3. Save the Word document as Lab05A_LastName_FirstInitial.

END OF PART A

Part B: Pig Latin

Step 1: Requirements
Write a program that will input a phrase and convert it to pig latin. Put each word in a separate element of a string array. Remove the first letter from each word and concatenate it to the end of the word followed by "ay."
Sample Output from Program:

* You will be prompted to enter a string of *
* words. The string will be converted into *
* Pig Latin and the results displayed. *
* Enter as many strings as you would like. *

Enter a group of words or ENTER to quit: Computer Programming is fun to learn!
Original words: Computer Programming is fun to learn!
New Words: omputercay ogrammingpray isway unfay otay earnlay!
Enter a group of words or ENTER to quit: Quit

Pig Latin Hint:

If a word begins with one or more consonants, move the consonant or consonant cluster to the end of the word. Add the letters "ay" to the end of the word. So, "pig" would be "igpay," and "latin" would be "atinlay."

Step 2: Processing Logic
Using the pseudocode below, write the code that will meet the requirements.
Main function
Display the heading
While the condition is true
Prompt the user for group of words or Enter to quit
Display original words
Call function pigLatinString( )
End while
pigLatinString( ) function
Declare and initialize string variables len, counter, start, begin, word and newString
While condition is true
Call find() and pass a space and start as parameters and return the returned value
to start
if start equals to string::npos
jump outside the loop permanently
call substr() function
display the word
update newString
increment start by one
assign start to begin
End While
Call substr()
Update newString
Return newString

Step 3: Create a New Project
Create a new project and name it LAB5B. Write your code using the Processing Logic in Part B, Step 2. Make sure you save your program.

Step 4: Compile and Execute
a) Compile your program. Eliminate all syntax errors.
b) Build your program and verify the results of the program. Make corrections to the program logic if necessary until the results of the program execution are what you expect.

Step 5: Print Screen Shots and Program
1. Capture a screen print of your output. (Do a PRINT SCREEN and paste into an MS Word document.)
2. Copy your code and paste it into the same MS Word document that contains the screen print of your output.
3. Save the Word document as Lab05B_LastName_FirstInitial.

Reference no: EM13919815

Questions Cloud

Equipment to produce specialized aluminum products : ALUM, Inc. uses high-tech equipment to produce specialized aluminum products for its customers. Each one of these machines costs $1,520,000 to purchase plus an additional $48,000 a year to operate. The machines have a five-year life after which they ..
Calculate the current zar spot exchange rates : Calculate the following exchange rates (ZAR and USD refer to the South African rand and U.S. dollar, respectively). The current ZAR spot rate in USD that would have been forecast by PPP.
Flotation costs for new issue : A $1,000 par value bond with a market price of $970 and a coupon interest rate of 10 percent. Flotation costs for a new issue would be approximately 5 percent. The bonds mature in 10 years and the corporate tax rate is 34 percent.
Key elements of the graduate program : Discuss the research of your chosen career conducted in Unit 4. List three key elements of the graduate program and discuss how each will impact your chosen career field. Analyze the importance of a graduate degree as it relates to your chosen career..
Explain the need for arrays in a program : You will code, build, and execute two programs requiring arrays and strings.  First program (Video Game Player Program): Determine the average score for a group of players and then determine who scored below average.
Control the functions of motion detection camera device : Project Title: A Specialized Simple RISC Machine (SSRC) To Control the Functions of Motion Detection Camera Device. One sentence Description of this new automated device: My RISC machine automates a motion detection camera by automaticall triggering..
Critical analysis of assignment problems in real life : Critical analysis of assignment problems in real life.(consider in industries and military)
How much accrued interest will shift between buyer-seller : In the case of a coupon bond being purchased 77 days since the last coupon payment of $76.21, how much accrued interest will shift between buyer and seller if bond pays semi-annual coupons (i.e. coupon payments are typically 180 days apart)?
Articles about the use of e-commerce shopping carts : Research and apply the content from recent articles about the use of e-Commerce Shopping carts. You must cite at least 3-5 sources outside of the class textbook.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Assignment on the hot topic in human computer interaction

Assignment on the hot topic in human computer interaction

  Where identifier is any valid identifier

Where identifier is any valid identifier and namespace-body is the set of classes, objects and functions that are included within the namespace.

  Managing a merger

Imagine you work for Quality Corporation (Quality.ad) who has just recently bought Crescent Inc. (Crescent.ad) in a recent merger. Quality and Crescent have separate offices in St. Louis (Quality HQ), Little Rock, and Austin (Crescent HQ). Crescen..

  Computer science question html website development

Design a preliminary homepage called "cssprelimI.htm". It should be similar in layout to the example below, but you may use your own content.

  Regular expression and regular sets that is not solvable

Give an example of a problem about FSAs, Regular Expression and Regular Sets that is not solvable?

  What relational algebra operator to find products

What relational algebra operator do you use to find products contained in every order? What relational algebra operator do you use to find products contained in any order

  Find probability of having no umbrella if it rains

When rain is forecast, Mr. Pickwick takes his umbrella. When rain is not forecast, he takes it with  probability 1/3. Find the probability that Pickwick has no umbrella, given that it rains.

  Write down a 3- to 5-page paper describing marketing plan

mcbride marketing paperresource virtual organization for mcbride financial servicesmcbride financial services wants to

  Write the statement that includes a friend function

Write the statement that includes a friend function named before in the class dateType that takes as parameters two objects of type dateType and returns true if the date represented by the first object comes before the date represented by the second ..

  Description of new information technology

.A full description of the new Information Technology (IT) system that you will propose to the Riordan organization during Week Nine of the course - Make sure that the four primary functions of an IT system are evident in the system that you propo..

  Our model assumes that the arrival distribution of customers

In the McBurgers simulation, our model assumes that the arrival distribution of customers is the same throughout the entire day. Do you think this is a realistic assumption? If not, explain how you could modify the model to make it a better repres..

  Acme films produces advertisements for cable television

Acme Films produces advertisements for cable television stations. They have two locations in a large metropolitan area. Building 1 contains the administrative, sales, marketing, human resources, development, and graphics departments

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd