Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Put into c++ Write a program that performs a survey tally on beverages. The prog

ID: 3680112 • Letter: P

Question

Put into c++ 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: Coffee Tea Coke Orange juice Sample Run: Pease input the favorite beverage of person #1: Choose 1, 2, 3, or 4 from the above menu or -1 to exit the program 4 Please input the favorite beverage of person #2: Choose 1, 2, 3, or 4 free the above menu or -1 to exit the program 1 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 Please input the favorite beverage of person 14: Choose I. 2. 3. or 4 froe the above aenu or -1 to exit the program 1 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 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 Tha total number of people surveyed is 5. The results are as follows: Beverage Number of Votes

Explanation / Answer

#include<iostream>

using namespace std;

int main(){
  
   cout<<"Choose 1.Coffee 2.Tea 3.Coke and 4.Orange Juice"<<endl;
  
   int coffee = 0, tea = 0, coke = 0, orange = 0;
  
   int op = 0;
   int total = 0;
  
   while(op != -1){
      
       cout<<"Please input the favorite beverage of person #1: Choose 1, 2, 3, or 4"
           <<" from the above menu or -1 to exit the program"<<endl;
       cin>>op;
      
       if(op == -1)
           break;
          
       switch(op){
          
           case 1: coffee++; break;
           case 2: tea++; break;
           case 3: coke++; break;
           case 4: orange++; break;
           default: cout<<"Invalid option"<<endl;
           }
       total++;
       }
      
       cout<<"The total number of people surveyed is "<<total<<". The result are as follows: "<<endl;
       cout<<"Beverage "<<"Number of Votes"<<endl;
       cout<<"************************************"<<endl;
       cout<<" Coffee "<<" "<<coffee<<endl;
       cout<<" Tea "<<" "<<tea<<endl;
       cout<<" Coke "<<" "<<coke<<endl;
       cout<<" Orange Juice "<<" "<<orange<<endl;
  
   return 0;
   }

/*

Output:

Choose 1.Coffee 2.Tea 3.Coke and 4.Orange Juice
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
Please input the favorite beverage of person #1: Choose 1, 2, 3, or 4 from the above menu or -1 to exit the program
1
Please input the favorite beverage of person #1: Choose 1, 2, 3, or 4 from the above menu or -1 to exit the program
3
Please input the favorite beverage of person #1: Choose 1, 2, 3, or 4 from the above menu or -1 to exit the program
1
Please input the favorite beverage of person #1: Choose 1, 2, 3, or 4 from the above menu or -1 to exit the program
1
Please input the favorite beverage of person #1: 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 result are as follows:
Beverage Number of Votes
************************************
Coffee 3
Tea 0
Coke 1
Orange Juice 1

*/