SlideShare ist ein Scribd-Unternehmen logo
1 von 10
DEVRY CIS 170 C iLab 5 of 7 Arrays and Strings
Check this A+ tutorial guideline at
http://www.cis170entirecourse.com/cis-170/cis-
170-c-ilab-5-of-7-arrays-and-strings
For more classes visit
http://www.cis170entirecourse.com
www.cisl70entirecourse.com
CIS 170 C iLab 5 of 7 Arrays and Strings
Lab # CIS CIS170C-A5 Lab 5 of 7: Arrays and
Strings 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:
Be able to explain the need for arrays in a
program. Be able to determine the appropriate
array data type to use in a given program. Be
able to write a program that implements arrays.
Be able to explain the way memory is allocated
for arrays in a program. Be able to explain the
fact that arrays are objects in C++. Be able to
write a program that implements
strings.Deliverables
Section
Deliverable
www.cisl70eP
™*
Step 5: Program Listing and Output
20
Part B
Step 5: Program Listing and Output
25
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. Numberofplayers
In the CalculateAverageScore function, calculate
^^the average score and return it by value.
p y
In the DisplayBelowAverage function, display the
name and score for any player who scored below
the average. Do not use global variables. Number
of players 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
www. cPr
?f any
p
key to cont
inu
e ■ ■ ■
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 W W WRetu™ 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 Capture a
screen print of your output. (Do a PRINT SCREEN
and paste into an MS Word document.) Copy your
code and paste it into the same MS Word
document that contains the screen print of your
output. 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: *-T-*
**
* 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. **-T-* *-!-» «-!-» «-!-» ^T-* «-!-» «-!-» ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-*
^T-* *-!-*
5fC5f«5i<
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:
omputercayogrammingprayiswayunfayotayearnla
y!
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”
WWW.CI
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
www.cisl7CEn
1
d
s
Whil
'!
0
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 Capture a
screen print of your output. (Do a PRINT SCREEN
and paste into an MS Word document.) Copy your
code and paste it into the same MS Word
document that contains the screen print of your
output. Save the Word document as
Lab05B_LastName_FirstInitial.
END OF LAB
www.cisl70entirecourse.com
necessary until the results of the program
execution are what you expect.
Step 5: Print Screen Shots and Program Capture a
screen print of your output. (Do a PRINT SCREEN
and paste into an MS Word document.) Copy your
code and paste it into the same MS Word
document that contains the screen print of your
output. Save the Word document as
Lab05B_LastName_FirstInitial.
END OF LAB
www.cisl70entirecourse.com

Weitere ähnliche Inhalte

Was ist angesagt?

05 control structures 2
05 control structures 205 control structures 2
05 control structures 2
Jomel Penalba
 

Was ist angesagt? (18)

Presentatie .NET 4/VS2010
Presentatie .NET 4/VS2010Presentatie .NET 4/VS2010
Presentatie .NET 4/VS2010
 
Session 5-exersice
Session 5-exersiceSession 5-exersice
Session 5-exersice
 
Introduction to goodenuffR
Introduction to goodenuffRIntroduction to goodenuffR
Introduction to goodenuffR
 
selection structures
selection structuresselection structures
selection structures
 
escape sequences and substitution markers
escape sequences and substitution markersescape sequences and substitution markers
escape sequences and substitution markers
 
Infix-Postfix expression conversion
Infix-Postfix expression conversionInfix-Postfix expression conversion
Infix-Postfix expression conversion
 
Introduction to SkyPat 2.0
Introduction to SkyPat 2.0Introduction to SkyPat 2.0
Introduction to SkyPat 2.0
 
My first program in c, hello world !
My first program in c, hello world !My first program in c, hello world !
My first program in c, hello world !
 
05 control structures 2
05 control structures 205 control structures 2
05 control structures 2
 
[Question Paper] ASP.NET With C# (75:25 Pattern) [April / 2015]
[Question Paper] ASP.NET With C# (75:25 Pattern) [April / 2015][Question Paper] ASP.NET With C# (75:25 Pattern) [April / 2015]
[Question Paper] ASP.NET With C# (75:25 Pattern) [April / 2015]
 
Infix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using StackInfix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using Stack
 
Infix postfixcoversion
Infix postfixcoversionInfix postfixcoversion
Infix postfixcoversion
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEW
 
Python Programming Essentials - M28 - Debugging with pdb
Python Programming Essentials - M28 - Debugging with pdbPython Programming Essentials - M28 - Debugging with pdb
Python Programming Essentials - M28 - Debugging with pdb
 
Metaprogramming
MetaprogrammingMetaprogramming
Metaprogramming
 
Preprocessor in C
Preprocessor in CPreprocessor in C
Preprocessor in C
 
C program to write c program without using main function
C program to write c program without using main functionC program to write c program without using main function
C program to write c program without using main function
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 

Ähnlich wie Devry cis-170-c-i lab-5-of-7-arrays-and-strings

COMP 2213X2 Assignment #2 Parts A and BDue February 3 in cla.docx
COMP 2213X2 Assignment #2 Parts A and BDue February 3 in cla.docxCOMP 2213X2 Assignment #2 Parts A and BDue February 3 in cla.docx
COMP 2213X2 Assignment #2 Parts A and BDue February 3 in cla.docx
donnajames55
 

Ähnlich wie Devry cis-170-c-i lab-5-of-7-arrays-and-strings (20)

Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and strings
 
COMP 2213X2 Assignment #2 Parts A and BDue February 3 in cla.docx
COMP 2213X2 Assignment #2 Parts A and BDue February 3 in cla.docxCOMP 2213X2 Assignment #2 Parts A and BDue February 3 in cla.docx
COMP 2213X2 Assignment #2 Parts A and BDue February 3 in cla.docx
 
Gsp 215 Effective Communication / snaptutorial.com
Gsp 215  Effective Communication / snaptutorial.comGsp 215  Effective Communication / snaptutorial.com
Gsp 215 Effective Communication / snaptutorial.com
 
Gsp 215 Believe Possibilities / snaptutorial.com
Gsp 215  Believe Possibilities / snaptutorial.comGsp 215  Believe Possibilities / snaptutorial.com
Gsp 215 Believe Possibilities / snaptutorial.com
 
ADLAB.pdf
ADLAB.pdfADLAB.pdf
ADLAB.pdf
 
Gsp 215 Enhance teaching-snaptutorial.com
Gsp 215 Enhance teaching-snaptutorial.comGsp 215 Enhance teaching-snaptutorial.com
Gsp 215 Enhance teaching-snaptutorial.com
 
GSP 215 Technology levels--snaptutorial.com
GSP 215 Technology levels--snaptutorial.comGSP 215 Technology levels--snaptutorial.com
GSP 215 Technology levels--snaptutorial.com
 
Gsp 215 Massive Success / snaptutorial.com
Gsp 215  Massive Success / snaptutorial.comGsp 215  Massive Success / snaptutorial.com
Gsp 215 Massive Success / snaptutorial.com
 
Gsp 215 Enthusiastic Study / snaptutorial.com
Gsp 215 Enthusiastic Study / snaptutorial.comGsp 215 Enthusiastic Study / snaptutorial.com
Gsp 215 Enthusiastic Study / snaptutorial.com
 
GSP 215 RANK Education Counseling -- gsp215rank.com
GSP 215 RANK Education Counseling -- gsp215rank.comGSP 215 RANK Education Counseling -- gsp215rank.com
GSP 215 RANK Education Counseling -- gsp215rank.com
 
GSP 215 RANK Education Your Life--gsp215rank.com
GSP 215 RANK Education Your Life--gsp215rank.comGSP 215 RANK Education Your Life--gsp215rank.com
GSP 215 RANK Education Your Life--gsp215rank.com
 
GSP 215 RANK Lessons in Excellence-- gsp215rank.com
GSP 215 RANK Lessons in Excellence-- gsp215rank.comGSP 215 RANK Lessons in Excellence-- gsp215rank.com
GSP 215 RANK Lessons in Excellence-- gsp215rank.com
 
GSP 215 RANK Inspiring Innovation--gsp215rank.com
GSP 215 RANK Inspiring Innovation--gsp215rank.com GSP 215 RANK Inspiring Innovation--gsp215rank.com
GSP 215 RANK Inspiring Innovation--gsp215rank.com
 
GSP 215 Education Organization - snaptutorial.com
GSP 215  Education Organization - snaptutorial.comGSP 215  Education Organization - snaptutorial.com
GSP 215 Education Organization - snaptutorial.com
 
Devry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-startedDevry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-started
 
Devry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-startedDevry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-started
 
Gsp 215 Exceptional Education / snaptutorial.com
Gsp 215  Exceptional Education / snaptutorial.comGsp 215  Exceptional Education / snaptutorial.com
Gsp 215 Exceptional Education / snaptutorial.com
 
Cmis 102 Effective Communication / snaptutorial.com
Cmis 102  Effective Communication / snaptutorial.comCmis 102  Effective Communication / snaptutorial.com
Cmis 102 Effective Communication / snaptutorial.com
 
GSP 215 RANK Introduction Education--gsp215rank.com
GSP 215 RANK Introduction Education--gsp215rank.comGSP 215 RANK Introduction Education--gsp215rank.com
GSP 215 RANK Introduction Education--gsp215rank.com
 
GSP 215 RANK Education Counseling--gsp215rank.com
 GSP 215 RANK Education Counseling--gsp215rank.com GSP 215 RANK Education Counseling--gsp215rank.com
GSP 215 RANK Education Counseling--gsp215rank.com
 

Mehr von noahjamessss

Mehr von noahjamessss (20)

Devry cis-170-c-i lab-7-of-7-sequential-files
Devry cis-170-c-i lab-7-of-7-sequential-filesDevry cis-170-c-i lab-7-of-7-sequential-files
Devry cis-170-c-i lab-7-of-7-sequential-files
 
Devry cis-170-c-i lab-6-of-7-menu
Devry cis-170-c-i lab-6-of-7-menuDevry cis-170-c-i lab-6-of-7-menu
Devry cis-170-c-i lab-6-of-7-menu
 
Devry cis-170-c-i lab-4-of-7-functions
Devry cis-170-c-i lab-4-of-7-functionsDevry cis-170-c-i lab-4-of-7-functions
Devry cis-170-c-i lab-4-of-7-functions
 
Devry cis-170-c-i lab-3-of-7-looping
Devry cis-170-c-i lab-3-of-7-loopingDevry cis-170-c-i lab-3-of-7-looping
Devry cis-170-c-i lab-3-of-7-looping
 
Devry cis-170-c-i lab-2-of-7-decisions
Devry cis-170-c-i lab-2-of-7-decisionsDevry cis-170-c-i lab-2-of-7-decisions
Devry cis-170-c-i lab-2-of-7-decisions
 
Devry busn-278-entire-course
Devry busn-278-entire-courseDevry busn-278-entire-course
Devry busn-278-entire-course
 
Busn 278-week-4-midterm
Busn 278-week-4-midtermBusn 278-week-4-midterm
Busn 278-week-4-midterm
 
Bus 650-week-6-final-paper-financial-analysis-the-lg-group
Bus 650-week-6-final-paper-financial-analysis-the-lg-groupBus 650-week-6-final-paper-financial-analysis-the-lg-group
Bus 650-week-6-final-paper-financial-analysis-the-lg-group
 
Ash bus-650-week-2-return-on-investment-education-funding
Ash bus-650-week-2-return-on-investment-education-fundingAsh bus-650-week-2-return-on-investment-education-funding
Ash bus-650-week-2-return-on-investment-education-funding
 
Ash bus-650-week-2-dq-2-managing-earnings
Ash bus-650-week-2-dq-2-managing-earningsAsh bus-650-week-2-dq-2-managing-earnings
Ash bus-650-week-2-dq-2-managing-earnings
 
Ash bus-650-week-2-dq-1-initial-investment
Ash bus-650-week-2-dq-1-initial-investmentAsh bus-650-week-2-dq-1-initial-investment
Ash bus-650-week-2-dq-1-initial-investment
 
Ash bus-650-week-1-dq-2-short-term-or-long-term-view
Ash bus-650-week-1-dq-2-short-term-or-long-term-viewAsh bus-650-week-1-dq-2-short-term-or-long-term-view
Ash bus-650-week-1-dq-2-short-term-or-long-term-view
 
Ash bus-650-ash-complete-class
Ash bus-650-ash-complete-classAsh bus-650-ash-complete-class
Ash bus-650-ash-complete-class
 
Keller hsm 541 week 7 course project due
Keller hsm 541 week 7 course project dueKeller hsm 541 week 7 course project due
Keller hsm 541 week 7 course project due
 
Hrm 326 final exam guide
Hrm 326 final exam guideHrm 326 final exam guide
Hrm 326 final exam guide
 
Mkt 421 final exam guide (new, 2017) new
Mkt 421 final exam guide (new, 2017) newMkt 421 final exam guide (new, 2017) new
Mkt 421 final exam guide (new, 2017) new
 
Uop phl 458 week 3 dq 1 new
Uop phl 458 week 3 dq 1 newUop phl 458 week 3 dq 1 new
Uop phl 458 week 3 dq 1 new
 
Uop phl 458 week 1 dq 1 new
Uop phl 458 week 1 dq 1 newUop phl 458 week 1 dq 1 new
Uop phl 458 week 1 dq 1 new
 
Uop str 581 week 4
Uop str 581 week 4Uop str 581 week 4
Uop str 581 week 4
 
Uop str 581 capstone final exam part 2 new
Uop str 581 capstone final exam part 2 newUop str 581 capstone final exam part 2 new
Uop str 581 capstone final exam part 2 new
 

Kürzlich hochgeladen

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 

Kürzlich hochgeladen (20)

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 

Devry cis-170-c-i lab-5-of-7-arrays-and-strings

  • 1. DEVRY CIS 170 C iLab 5 of 7 Arrays and Strings Check this A+ tutorial guideline at http://www.cis170entirecourse.com/cis-170/cis- 170-c-ilab-5-of-7-arrays-and-strings For more classes visit http://www.cis170entirecourse.com www.cisl70entirecourse.com CIS 170 C iLab 5 of 7 Arrays and Strings Lab # CIS CIS170C-A5 Lab 5 of 7: Arrays and Strings 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.
  • 2. Second program (Pig Latin): Convert words in a phrase to pig latin. Learning outcomes: Be able to explain the need for arrays in a program. Be able to determine the appropriate array data type to use in a given program. Be able to write a program that implements arrays. Be able to explain the way memory is allocated for arrays in a program. Be able to explain the fact that arrays are objects in C++. Be able to write a program that implements strings.Deliverables Section Deliverable www.cisl70eP ™* Step 5: Program Listing and Output 20 Part B Step 5: Program Listing and Output 25 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.
  • 3. 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. Numberofplayers In the CalculateAverageScore function, calculate ^^the average score and return it by value. p y In the DisplayBelowAverage function, display the name and score for any player who scored below the average. Do not use global variables. Number of players 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
  • 4. 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 www. cPr ?f any p key to cont inu e ■ ■ ■ 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
  • 5. 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 W W WRetu™ 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
  • 6. necessary until the results of the program execution are what you expect. Step 5: Print Screen Shots and Program Capture a screen print of your output. (Do a PRINT SCREEN and paste into an MS Word document.) Copy your code and paste it into the same MS Word document that contains the screen print of your output. 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: *-T-* ** * 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. **-T-* *-!-» «-!-» «-!-» ^T-* «-!-» «-!-» ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* ^T-* *-!-* 5fC5f«5i<
  • 7. 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: omputercayogrammingprayiswayunfayotayearnla y! 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” WWW.CI 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
  • 8. 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 www.cisl7CEn 1 d s Whil '! 0 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
  • 9. necessary until the results of the program execution are what you expect. Step 5: Print Screen Shots and Program Capture a screen print of your output. (Do a PRINT SCREEN and paste into an MS Word document.) Copy your code and paste it into the same MS Word document that contains the screen print of your output. Save the Word document as Lab05B_LastName_FirstInitial. END OF LAB www.cisl70entirecourse.com
  • 10. necessary until the results of the program execution are what you expect. Step 5: Print Screen Shots and Program Capture a screen print of your output. (Do a PRINT SCREEN and paste into an MS Word document.) Copy your code and paste it into the same MS Word document that contains the screen print of your output. Save the Word document as Lab05B_LastName_FirstInitial. END OF LAB www.cisl70entirecourse.com