22.4k views
1 vote
The attached program (studentsGpa.cpp) uses dynamic allocation to create an array of strings. It asks the user to enter a number and based on the entered number it allocates the array size. Then based on that number it asks the user that many times to enter student’s names. What you need to do:Add another array of doubles to store the gpa of each student as you enter themYou need to display both the student’s name and the gpa.NOTE: must use pointer notation not array subscript. Any submission that uses array subscript won’t be graded

1 Answer

3 votes

Question: The program was not attached to your question. Find attached of the program and the answer.

Answer:

See the explanation for the answer.

Step-by-step explanation:

#include <iostream>

using namespace std;

int main()

{

cout << "How many students will you enter? ";

int n;

cin>>n;

string *name = new string[n];

double *gpa = new double[n];

for(int i=0;i<n;i++){

cout<<"Enter student"<<(i+1)<<"'s name: ";

cin>>name[i];

cout<<"Enter student"<<(i+1)<<"'s gpa: ";

cin>>gpa[i];

}

cout<<"The list students"<<endl;

cout<<"Name GPA"<<endl;

cout<<"----------------------"<<endl;

for(int i=0;i<n;i++){

cout<<name[i]<<" "<<gpa[i]<<endl;

}

return 0;

}

OUTPUT : See the attached file.

The attached program (studentsGpa.cpp) uses dynamic allocation to create an array-example-1
The attached program (studentsGpa.cpp) uses dynamic allocation to create an array-example-2
User Pynchia
by
6.1k points