Modify the following code to print out the class list in the following format Sl
ID: 3659145 • Letter: M
Question
Modify the following code to print out the class list in the following format
Sl FirstName LastName ID Grade
1 Do Little 4444 98
2 Adam Strong 1111 87
3 Dan Martin 5555 86
4 Stuart Little 3333 78
5 Brian Adams 2222 69
#include <iostream>
#include <string>
using namespace std;
struct Student{
string firstname, lastname;
int ID;
float score;
};
int main()
{
cout<<"Enter the size of the array: ";
int sz; cin>>sz;
Student *sPtr = new Student[sz];
cout<<"Let's populate the array ";
for(int i=0; i<sz; i++)
{
cout<<"Enter the firt name followed by last name: ";
cin>>sPtr[i].firstname;
cin>>sPtr[i].lastname;
cout<<"Enter ID for "<<sPtr[i].firstname<<": ";
cin>>sPtr[i].ID;
cout<<"Enter score for "<<sPtr[i].firstname<<": ";
cin>>sPtr[i].score;
cout<<endl;
}
cout<<"Let's print the class list ";
}
Explanation / Answer
#include #include using namespace std; struct Student { string firstname, lastname; int ID; float score; }; int main() { cout>sz; Student *sPtr = new Student[sz]; cout>sPtr[i].lastname; coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.