# Programming Problems

Page 1 of 1

## 2 Replies - 615 Views - Last Post: 19 November 2009 - 10:28 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=140325&amp;s=d34f6d64f5b59b66abb49f9ddc6d2899&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 airlaflair

Reputation: 0
• Posts: 24
• Joined: 20-October 09

# Programming Problems

Posted 19 November 2009 - 09:49 PM

```// Program Favorit determines the favorite soft drink.
#include <iostream>
using namespace std;
enum DrinksType {COKE, PEPSI, SPRITE, DR_PEPPER};
void Prompt();
// This function provides the input prompts.
int main ()
{
int sums[4];
int number;
DrinksType index;
for (index = COKE; index <= DR_PEPPER; index = DrinksType(index+1))
// FILL IN code to set sums to zero
Prompt();
cin >> number;
while (number != 4)
{
// FILL IN code to increment the proper drink
Prompt();
cin >> number;
}
// FILL IN code to write out the totals
return 0;
}
//*******************************************************
void Prompt()
{
cout << "Enter a 0 if your favorite is a Coke." << endl;
cout << "Enter a 1 if your favorite is a Pepsi." << endl;
cout << "Enter a 2 if your favorite is a Sprite." << endl;
cout << "Enter a 3 if your favorite is a Dr. Pepper." << endl;
cout <<"Enter a 4 if you wish to quit the survey." << endl;
}
```

Exercise 1: Complete program Favorit and run it. Which data did you use? What did
the program write?

Exercise 2: Add a function to program Favorit that sums the number of responses to
the survey. Pass the array sums as a parameter. Print the number of responses on the
screen. Run the program with the same data you used in Exercise 1. How many
responses were there?

Exercise 3: Add a function that takes the array sums as a parameter and prints the
percentage of responses each drink received. Run your program on the same data.
Show the results.

Is This A Good Question/Topic? 0

## Replies To: Programming Problems

### #2 airlaflair

Reputation: 0
• Posts: 24
• Joined: 20-October 09

## Re: Programming Problems

Posted 19 November 2009 - 10:18 PM

anyone?

### #3 ComputerAnalysis

Reputation: 8
• Posts: 92
• Joined: 29-June 09

## Re: Programming Problems

Posted 19 November 2009 - 10:28 PM

Ya buddy, we don't do homework here.