Question

[Soft Drinks Survey] Write a program that performs a survey tally on beverages. The program should prompt for the next person until a sentinel value of –1 is entered to terminate the program. Each person participating in the survey should choose their favorite beverage from the following list:
1. Coffee
2. Tea
3. Coke
4. Orange Juice

Sample Run:
Soft Drink Survey
1. Coffee
2. Tea
3. Coke
4. Orange Juice
5. Please enter -1 to exit
Please input the favorite beverage of person #1: Choose 1, 2, 3, or 4 from the above menu or -1 to exit the program
4

Soft Drink Survey
1. Coffee
2. Tea
3. Coke
4. Orange Juice
5. Please enter -1 to exit
Please input the favorite beverage of person #2: Choose 1, 2, 3, or 4 from the above menu or -1 to exit the program
1

Soft Drink Survey
1. Coffee
2. Tea
3. Coke
4. Orange Juice
5. Please enter -1 to exit
Please input the favorite beverage of person #3: Choose 1, 2, 3, or 4 from the above menu or -1 to exit the program
3

Soft Drink Survey
1. Coffee
2. Tea
3. Coke
4. Orange Juice
5. Please enter -1 to exit
Please input the favorite beverage of person #4: Choose 1, 2, 3, or 4 from the above menu or -1 to exit the program
1

Soft Drink Survey
1. Coffee
2. Tea
3. Coke
4. Orange Juice
5. Please enter -1 to exit
Please input the favorite beverage of person #5: Choose 1, 2, 3, or 4 from the above menu or -1 to exit the program
1

Soft Drink Survey
1. Coffee
2. Tea
3. Coke
4. Orange Juice
5. Please enter -1 to exit Please input the favorite beverage of person #6: Choose 1, 2, 3, or 4 from the above menu or -1 to exit the program
-1

The total number of people surveyed is 5. The results are as follows:
Beverage Number of Votes
********************************
Coffee 3
Tea 0
Coke 1
Orange Juice 1

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

int main(int argc, char** argv) {
   
    string firstMessage = " Soft Drink Survey\n";
    firstMessage += "\t1. Coffee\n";
    firstMessage += "\t2. Tea\n";
    firstMessage += "\t3. Coke\n";
    firstMessage += "\t4. Orange Juice\n";
    firstMessage += "\t5. Please enter -1 to exit\n";
    firstMessage += "\nPlease input the favorite beverage of person #" ;
   
    string secondMessage = ": Choose 1, 2, 3, or 4 from the\n";
    secondMessage += "above menu or -1 to exit the program\n";...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Assisting Tutor

Related Homework Solutions

C++ Classes Problems
Homework Solution
$15.00
Computer Science
C++ Programming
Algorithms
Classes
Arrays
Declarations
Variables
Operations
Member Functions
C# Programming Problems
Homework Solution
$40.00
Computer Science
C# Programming
Libraries
Methods
Strings
Customers
Arrays
Interfaces
List Boxes
Buttons
Operations
Simple Phone Book Using C++
Homework Solution
$30.00
Computer Science
Phone Book
C++ Programming
Linked Lists
Classes
Data
Functionality
Parameters
Alphabetical Order
Insertion Points
Loops
Game Tournaments Using Linked Structures in C++
Homework Solution
$48.00
Computer Science
C++ Programming
Linked Structures
Tournaments
Nodes
Elements
Characters
Functions
Abstract Data Types
Variables
Header Files
Parameters
Losers
Winners
Random Draw
Teams
Reflections
Testing
Orders
Number Processing in C#
Homework Solution
$50.00
Computer Science
Number Processing
C#
Text Boxes
Summation
Average Numbers
Sorting
Input Files
Variables
Forms
Randomization
Variable Length Encoding Using C Programming
Homework Solution
$84.00
Computer Science
C Programming
Variable Length Encoding
Standard Output
Sequences of Bits
Strings
Characters
Zeros
Stream
Text Files
Huffman Code
Functions
Get help from a qualified tutor
Live Chats