Chapter 2 – Q #18 Energy Drink Consumption – Tony Gaddis – Starting Out With C++

Chapter 2 – Q #18    Energy Drink Consumption – Tony Gaddis – Starting Out With C++



Problem: -

A soft drink company recently surveyed 12,467 of its customers and found that approximately 14 percent of those surveyed purchase one or more energy drinks per week. Of those customers who purchase energy drinks, approximately 64 percent of them prefer citrus flavored energy drinks. Write a program that displays the following:

  • The approximate number of customers in the survey who purchase one or more energy drinks per week
  • The approximate number of customers in the survey who prefer citrus flavored energy drinks

Solution: -

#include <iostream>

using namespace std;

int main()

{

      const float custmor = 12467,

            one_or_more = 0.14,

            citrus_flavour = 0.64;

      int more_drink_buyer, flavour_buyer;

      more_drink_buyer = one_or_more * custmor;

      flavour_buyer = citrus_flavour * custmor;

      cout << "Number Of Custmors Who Buy One or More Drinks in a Weak:   " << more_drink_buyer << endl;

      cout << "Number of Customors Who Buy Citrus Flavour:                " << flavour_buyer << endl;

      return 0;

}

This is the solution of this question




OUTPUT OF THIS QUESTION



Explanation of this Solution


  1. Declare three float constants custmor,  one_or_more and citrus_flavour and initialize given values.
  2. Declare two int variables for calculation.
  3. Calculate number of customers who purchase one or more energy drinks.
  4. Calculate number of customers who prefer citrus flavored energy drinks.
  5.  In last, display output on the screen and use endl for new line.
  6. Return 0 to the main function.

Also, I attach CPP file of this problem. You can download this file

Click Here to Download This File




Thanks!  



Post a Comment

0 Comments