This will be a menu-driven program. The menu should look like this: Menu ==== 1. Addition of non-negative numbers 2. Alphabetize strings 3. Exit Enter your choice: If the user chooses #1 in the menu, your program should ask the user for 2 integers, then print them and their total. Keep doing this entire process until at least one of the numbers is negative. At that point, the program should print a message that at least one of the numbers is negative. Ex: if the user enters 13 and 2, the output would look like: You entered 13 and 2 Neither is negative Their total is 15 (and the loop should execute again) Ex: if the user enters 100 and -7, the output would look like: You entered 100 and -7 At least one is negative (notice no total is printed and the loop should NOT execute again) If the user chooses #2 in the menu, your program should ask the user for 2 lowercase strings (assume the user will enter lowercase strings) and tell which would come first alphabetically in the form shown in the examples. Keep doing this entire process until one of the strings is "stop". Ex: if the user enters "help" and "hello", the output would look like: 'hello' comes before 'help' alphabetically (and the loop should execute again) Ex: if the user enters "abcdefg" and "abcdefh", the output would look like: 'abcdefg' comes before 'abcdefh' alphabetically (and the loop should execute again) Ex: if the user enters “aaaaa" and "stop", the output would look like: Program is over (notice no comparison is printed and the loop should NOT execute again) Your program should continue to print the menu, get the user's choice, and print the results until the user enters #3 on the menu, at which time your program should print a short message telling the user the program is over, and the program ends.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
This document outlines the requirements for a menu-driven program with the following features:

**Menu Structure:**

1. Addition of non-negative numbers
2. Alphabetize strings
3. Exit

**Program Instructions:**

- **Option 1: Addition of Non-negative Numbers**
  - The program should prompt the user to enter two integers. If both numbers are non-negative, their total is displayed, and the loop continues. If at least one of the numbers is negative, a message is printed, and the loop stops.

  **Example Scenarios:**
  - User enters `13` and `2`:
    ```
    You entered 13 and 2
    Neither is negative
    Their total is 15
    ```
    (Loop continues)
  - User enters `100` and `-7`:
    ```
    You entered 100 and -7
    At least one is negative
    ```
    (Loop stops)

- **Option 2: Alphabetize Strings**
  - The program prompts the user for two lowercase strings and informs them which string comes first alphabetically. This process repeats until the user inputs "stop".

  **Example Scenarios:**
  - User enters `"help"` and `"hello"`:
    ```
    'hello' comes before 'help' alphabetically
    ```
    (Loop continues)
  - User enters `"abcdefg"` and `"abcdefh"`:
    ```
    'abcdefg' comes before 'abcdefh' alphabetically
    ```
    (Loop continues)
  - User enters `"aaaaa"` and `"stop"`:
    ```
    Program is over
    ```
    (Loop stops)

- **Option 3: Exit**
  - When the user selects this option, the program will display a short message indicating termination and will then end.

**Program Requirements:**

1. Implement a switch statement for handling menu choices, ensuring all input and output are contained within the switch.
2. Use a do-while loop to maintain program operation until the user decides to exit.
3. Utilize loops within each menu selection.
4. If the user inputs an invalid option, the program should display an error message explaining the issue.
Transcribed Image Text:This document outlines the requirements for a menu-driven program with the following features: **Menu Structure:** 1. Addition of non-negative numbers 2. Alphabetize strings 3. Exit **Program Instructions:** - **Option 1: Addition of Non-negative Numbers** - The program should prompt the user to enter two integers. If both numbers are non-negative, their total is displayed, and the loop continues. If at least one of the numbers is negative, a message is printed, and the loop stops. **Example Scenarios:** - User enters `13` and `2`: ``` You entered 13 and 2 Neither is negative Their total is 15 ``` (Loop continues) - User enters `100` and `-7`: ``` You entered 100 and -7 At least one is negative ``` (Loop stops) - **Option 2: Alphabetize Strings** - The program prompts the user for two lowercase strings and informs them which string comes first alphabetically. This process repeats until the user inputs "stop". **Example Scenarios:** - User enters `"help"` and `"hello"`: ``` 'hello' comes before 'help' alphabetically ``` (Loop continues) - User enters `"abcdefg"` and `"abcdefh"`: ``` 'abcdefg' comes before 'abcdefh' alphabetically ``` (Loop continues) - User enters `"aaaaa"` and `"stop"`: ``` Program is over ``` (Loop stops) - **Option 3: Exit** - When the user selects this option, the program will display a short message indicating termination and will then end. **Program Requirements:** 1. Implement a switch statement for handling menu choices, ensuring all input and output are contained within the switch. 2. Use a do-while loop to maintain program operation until the user decides to exit. 3. Utilize loops within each menu selection. 4. If the user inputs an invalid option, the program should display an error message explaining the issue.
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education