Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The information used to complete this question is from zybooks C programming, Chapter 5 - Arrays. The program being used is visual studio 2015. win32

The information used to complete this question is from zybooks C programming, Chapter 5 - Arrays.

The program being used is visual studio 2015. win32 Console Application, C coding.

image text in transcribed

Football Score Write a program to keep track of a football score. Using a loop the runs 4 times, ask the user for the number of points scored in each quarter of a football game by both the home team and the away team. Store the number of points scored in each quarter in 2 arrays one for the home team and one for the away team. Create a constant for the size of the arrays. If you want, make the arrays 1 element bigger than needed and disregard element [0]. Then, display the scores for the 2 teams after each quarter -Use an outer loop to cycle through the 4 quarters of the game, and a nested inner loop to cycle through the number of quarters up to that point, accumulating the score up to that quarter. Finally, output a message as to who won the game. Validate that the scores entered are numbers that are 0 or greater, and continue to ask for the number until the score entered is O or greater Have a blank line between the input and the output. Hints: . . . . . . Validation error messages are indented 3 spaces Use tabs to create the columns and spaces to align the output as shown Use dashes ("-") to create the lines below "H" and "A" When displaying the score for each quarter, don't forget to reset the score before accumulating The inner loop for accumulating the score from 1 to the quarter you are accumulating for You will need a decision to display which team won . Don't oet the b le before 'Press any key to continue.." Example Run #1 bold type is what is entered by the user) How many points were scored by the Home team in quarter #1? -7 The number entered cannot be negative. Please re-enter the score: 7 How many points were scored by the Away team in quarter #1? 0 How many points were scored by the Home team in quarter #2? 7 How many points were scored by the Away team in quarter #2? 0 How many points were scored by the Home team in quarter #3? 0 How many points were scored by the Away team in quarter #3? 7 How many points were scored by the Home team in quarter #42 3 How many points were scored by the Away team in quarter #42 3 After each quarter, the score was: 01 23 24 Yea! The Home Team Won! 14 14 17 10 Example Run #2: How many points were scored by the Home team in quarter #1? 0 How many points were scored by the Away team in quarter #1? 7 How many points were scored by the Home team in quarter #2? 7 How many points were scored by the Away team in quarter #2? 0 How many points were scored by the Home team in quarter 43? 0 How many points were scored by the Away team in quarter 0 How many points were scored by the Home team in quarter #42 0 How many points were scored by the Away team in quarter #42 3 After each quarter, the score was: 21 Q3 04 Sorry, the Away Team won 10 The example runs show EXACTLY how your program input and output will look. Additional message If the score is tied, display "After 4 quarters, the score was tied

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions