Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions

Question

13. You always should try to make a good first impression.

Answered: 1 week ago