Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Multidimensional Arrays Code this Pseudocode save your file as 2dimensionalArray

ID: 3801262 • Letter: M

Question

Multidimensional Arrays Code this Pseudocode save your file as 2dimensionalArray your output should look like ENDev-CpplConsolepauser.exe start 1 3 4 5 Declarations 4 6 8 10 6 9 12 15 Constant num WIDTH 35 Process exited with return value 0 Constant num HEIGHT 3 Press any key to continue Num areaArray [HEIGHT][WIDTH] Num n,m //loop counters for (n 0 to HEIGHT step 1) output n+1 output height for (m 0 to WIDTH step 1) areaArray[n][m] (n+1)*(m+1) //calculate HEIGHT WIDTH and store it in the array output areaArray[n][m] endfor endfor end Programming Logic and Design, Seventh Edition

Explanation / Answer

// C++ code
#include <iostream>
using namespace std;
int main()
{
int rates[5][5]={{30,60,88,115,140},
{26,52,70,96,120},
{24,46,67,89,110},
{22,40,60,75,88},
{20,35,50,66,84}
};
int weeklyRate;
int numDays;   
int age;
int QUIT = 99;
cout << " Enter age of child or 99 to quit: "<<endl;
cin >> age;
while(age != QUIT)
{
cout << "Enter number of Days(1-5): "<<endl;
cin >> numDays;
  
if(age>4) // Because it doesn't matter the age of children after 4 year
age=4;

weeklyRate = rates[age][numDays-1];
  
cout<<"Weekly rate for the children is "<<weeklyRate<<endl;
  
cout << " Enter age of child or 99 to quit: "<<endl;
cin>>age;
}
  
cout << "End of program" << endl;
return 0;
}

/*
output:

Enter age of child or 99 to quit:
3
Enter number of Days(1-5):
2
Weekly rate for the children is 40

Enter age of child or 99 to quit:
4
Enter number of Days(1-5):
3
Weekly rate for the children is 50

Enter age of child or 99 to quit:
1
Enter number of Days(1-5):
2
Weekly rate for the children is 52

Enter age of child or 99 to quit:
5
Enter number of Days(1-5):
3
Weekly rate for the children is 50

Enter age of child or 99 to quit:
3
Enter number of Days(1-5):
4
Weekly rate for the children is 75

Enter age of child or 99 to quit:
99
End of program

*/