Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
5th Edition
ISBN: 9780134801155
Author: Tony Gaddis
Publisher: PEARSON
Question
Book Icon
Chapter 11, Problem 7PE
Program Plan Intro

The speed of the sound

Program Plan:

  • Include the required header files.
  • Define the main(),
    • Declare the required variables.
    • Display the menu options on the screen.
    • Get the choice from the user.
    • Using switch case,
      • Validate the user choice
        • Case 1:
          • Set the corresponding speed for “Air”.
          • Get the number of seconds that the sound travels.
          • Calculate the total distance amount.
        • Case 2:
          • Set the corresponding speed for “Water”.
          • Get the number of seconds that the sound travels.
          • Calculate the total distance amount.
        • Case 3:
          • Set the corresponding speed for “Steel”.
          • Get the number of seconds that the sound travels.
          • Calculate the total distance amount.
        • Case 4: Exit the program.

Blurred answer
Students have asked these similar questions
The program below display the following menu:Geometry Calculator1. Calculate the Area of a Circle2. Calculate the Area of a Rectangle3. Calculate the Area of a Triangle4. Quit Enter your choice (1-4):If the user enters 1, the program should ask for the radius of the circle and then display its area. Use 3.14159 for . If the user enters 2, the program should ask for the length and width of the rectangle, and then display the rectangle’s area. If the user enters 3, the pro- gram should ask for the length of the triangle’s base and its height, and then display its area. If the user enters 4, the program should end. Input Validation: Display an error message if the user enters a number outside the range of 1 through 4 when selecting an item from the menu. Do not accept negative values for the circle’s radius, the rectangle’s length or width, or the triangle’s base or height. You are therefore, required to complete the program by putting in codes under each comment.include…
# Constants for the menu choices# Constants for the menu choicesPURCHASE_ADULT = 1PURCHASE_CHILD = 2PURCHASE_MOUSE_EARS = 3PURCHASE_PARKING = 4PURCHASE_FOOD = 5PRINT_ALL = 6CALC_TOTAL = 7QUIT_CHOICE = 8# The main function.def main():# The choice variable controls the loop# and holds the user's menu choice.    choice = 0    costAdult=0    costKid=0    costEars=0    costPark=0    costFood = 0    while choice != QUIT_CHOICE:# display the menu.    display_menu()# Get the user's choice.        choice = int(input('Enter your choice: '))# Perform the selected action.        if choice == PURCHASE_ADULT:                costAdult = purchaseAdult()                elif choice == PURCHASE_CHILD:                costKid = purchaseKid()                elif choice == PURCHASE_MOUSE_EARS:                costEars = purchaseEars()                elif choice == PURCHASE_PARKING:                    costPark = purchaseParking();                    elif choice == PURCHASE_FOOD:                        costFood…
A custom tailor offers a variety of custom suit options to customers.  The company has tasked you with creating a program that will allow tailors to enter information about the kind of material used to make the customer's custom suit and the number of square yards used to make the suit and will determine the total cost to charge the customer. Use the following steps to create the program: The program should display a menu that asks the technician to select the type of material that was used.  Make sure the menu is formatted exactly as in the Sample Input and Output of the instructions (including indentation).   The program should determine the cost per square yard of the material.  The cost per square yard is determined based on the type of material that is used. Table 1: Type of Material and Cost per Square Yard   The program should then ask the tailor to enter the number of square yards of material that they used to make the custom suit.   Calculate the material cost, which…

Chapter 11 Solutions

Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education