Create an application that does the following tasks: 1. The main part of the pro
ID: 3621979 • Letter: C
Question
Create an application that does the following tasks:
1. The main part of the program will coordinate the tasks in the application.
2. In a separate method, you will:
a. create an array that lists 10 types of food.
b. collect user input in a separate array that rates each food from 1 - 10
3. In a third method you will output each food and its rating.
4. You will collect the input in a loop.
5. Your program will not allow the user to proceed with rating the next food item until a valid number from 1 - 10 is entered. In other words, if the user enters the number 12 for a food item, your program will not progress to the next food item. It will ask the user to enter a valid number for that food item. Here is a sample of a possible data entry session, including what should happen if the user enters an incorrect number (the numbers in red are the user's input):
Please rate beans from 1 - 10: 6
Please rate spinach from 1 - 10: 12
Please rate spinach from 1 - 10: 13
Please rate spinach from 1 - 10: 9
Please rate apples from 1 - 10: 8
Please rate pears from 1 - 10: 7
And so on...
Note: You will collect the data for only one user. The third method will create output that is different than the example above. The output should like like this:
{users name} rated beans as 6
{users name} rated spinach as 9
{users name} rated apples as 8
{users name} rated pears as 7
Explanation / Answer
Hope this helps. Let me know if you have any questions. Please rate. :) Here it is in C++. It'd be fairly easy to convert it to C or Java, if you'd like. #include #include using namespace std; const int ARRAY_SIZE = 10; void initializeFoodArray(string foods[]) { foods[0] = "beans"; foods[1] = "spinach"; foods[2] = "apples"; foods[3] = "pears"; foods[4] = "oranges"; foods[5] = "salami"; foods[6] = "juice"; foods[7] = "milk"; foods[8] = "cheese"; foods[9] = "cake"; } void getRatings(string foods[], int ratings[]) { bool success; for (int i = 0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.