Fancines Frozen yogurt stand is having a monthly contest amo

Fancines Frozen yogurt stand is having a monthly contest amongst its 4 servers to determine who can sell the most large yogurt cones. The winner will receive a $100 gift card to Amazon. The manager of Francines has asked you to develop a program to determine the winner. In C++, the program must allow the user to enter the names of the servers and the number of large yogurt cones they each sold. The program is to output each server\'s name, the number of cones they sold, and the percentage of the total large cones sold by the server that month. The program must also output the winner of the contest.

Sample Output:

Server Larges Cones Sold % of Total Cones

Mathers 345   25.38

Conte           210      5.45

Johnson                        533       39.22

Perry            271    19.94

Total        1359

The winner of the contest is Johnson.

Solution

// C++ code
#include <iostream>
#include <iomanip>
#include <string.h>
#include <limits.h>
using namespace std;

int main()
{
   string server[4];
   int coneSold[4];
   double total = 0;
   int max = INT_MIN;
   int maxIndex = 0;

   for (int i = 0; i < 4; ++i)
   {
       cout << \"Enter server name: \";
       cin >> server[i];
       cout << \"Enter larges cones sold: \";
       cin >> coneSold[i];
      
       if(coneSold[i] > max)
       {
           maxIndex = i;
           max = coneSold[i];
       }

       total = total + coneSold[i];
   }

  
   cout << \"\ \ Server\\t Larges Cones Sold\\t% of Total Cones\ \";
   for (int i = 0; i < 4; ++i)
   {
       cout << server[i] << \"\\t\\t\" << coneSold[i] << \"\\t\\t\" << 100*(coneSold[i]/total) << endl;
      
   }

   cout << \"The winner of the contest is \" << server[maxIndex] << endl;
   return 0;
}


/*
output:

Enter server name: Mathews
Enter larges cones sold: 345
Enter server name: Conte
Enter larges cones sold: 210
Enter server name: Johnson
Enter larges cones sold: 533
Enter server name: Perry
Enter larges cones sold: 271

Server   Larges Cones Sold   % of Total Cones
Mathews       345       25.3863
Conte       210       15.4525
Johnson       533       39.22
Perry       271       19.9411
The winner of the contest is Johnson

*/

Fancines Frozen yogurt stand is having a monthly contest amongst its 4 servers to determine who can sell the most large yogurt cones. The winner will receive a
Fancines Frozen yogurt stand is having a monthly contest amongst its 4 servers to determine who can sell the most large yogurt cones. The winner will receive a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site