Question: Question 1 Write a few lines of C++ which does the following: Output a statement to ask the user to input the numbers of innings

Question 1

Write a few lines of C++ which does the following:

  • Output a statement to ask the user to input the numbers of innings today's pitcher pitched. Store the user's response in a variable numInnings of type int
  • Output a statement to ask the user to input the numbers of runs today's pitcher gave up. Store the user's response in another variable numRuns of type int
  • Calculate the pitcher's ERA using the following formula: ERA = numRuns * 9 / numInnings
  • Output the ERA to the screen

Question 2

Write a few lines of C++ which does the following:

  • Output a statement to ask the user to input the score for the home team today, and store the user's response in a variable homeScoreof type int
  • Output a statement to ask the user to input the score for the visitor team today, and store the user's response in a variable visitorScore of type int
  • Display the scores, and tell the user who won the game
  • Also, tell the user if any of the following happened:
    • One of the teams had a low score (<3)
    • Both of the teams had a low score
    • Use a const int for a low score instead of the magic number of 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!