I really need help I don\'t think I\'m doing this right at all. I\'mcompletely l
ID: 3614393 • Letter: I
Question
I really need help I don't think I'm doing this right at all. I'mcompletely lost on arrays. Here is what I have to do..Riley Residence Hall charges different rates for semester room andboard based on the number of meals per day the student wants. Thesemester rate with no meals is $300. With one meal per day, therate is $450. With two meals per day, the rate is $520, and withthree meals per day, the rate is $590.
-Store these rates in an array.
-Write a program that allows a student to enter the number of mealsdesired per day.
-Output the semester room and board rate.
-Place the program in a loop where it will continue to processstudent rates until 9 is entered for the number of meals.
-Use the following input in the order given: 2, 0, 3, 1, 9
Here's what I have but I have a feeling i'm doing it wrong.
*Will rate Lifesaver*
#include<iostream.h>
void main ()
{
const int arraySize = 5;
int totalMeals[arraySize] = {2, 0, 3, 1, 9};
int rate[arraySize] = {$300, $450, $520, $590,$940};
int neededMeal;
int x;
cout<<"Enter how many meals ";
cin>>neededMeal;
for (x = 0; x< arraySize; ++x)
if (neededMeal == totalMeals[x])
cout<<"The rate is"<<rate[x]<<endl;
getch();
}