subject

Consider the following C++ program that makes use of many features that are unique to C++ and did not exist in C. #include #include #include #include
using namespace std;
enum LetterGrade { A = 4,
B = 3, C = 2, D = 1, F=0
};
// type T must be castable into a double template
double getArrayAverage(vector& vec) {
double sum = 0;
for (const auto& value : vec) {
sum += static_cast(value); }
const auto avg = sum / vec. size();
return avg; }
void convertCharToLetterGrade(char& grade) { switch (grade) {
case 'A': case 'a': grade = 4;
return;
case 'B': case 'b':
grade = 3;
return;
case 'C': case 'c':
grade = 2;
return;
case 'D': case 'd':
grade = 1;
return;
case 'F': case 'f':
grade = 0; return;
} }
LetterGrade if (avg
default:
cout << "Warning... Invalid Character... Recording an F.\n"; return;
(const double avg) {
>= 90)
return LetterGrade::A;
else if (avg >= 80) return LetterGrade::B;
else if (avg >= 70) return LetterGrade::C;
else if (avg >= 60) return LetterGrade::D;
else
return LetterGrade::F;
}
int main() {
string firstName;
cout << "Please enter your cin >> firstName;
string lastName;
cout << "Please enter your cin >> lastName;
first name: ";
last name: ";
int32_t numPrevCourses;
cout << "Enter number of previous courses: ";
cin >> numPrevCourses;
cin. ignore();
vector prevGrades(numPrevCourses);
for (int32_t courseIx = 0; courseIx < numPrevCourses; ++courseIx) {
cout << "Enter letter grade for course " << courseIx << ": "; char letterGrade;
cin. get(letterGrade);
cin. ignore();
convertCharToLetterGrade(letterGrad e);
prevGrades. at(courseIx) = static_cast(letterGrade); }
int32_t numEx; // (Exam)
cout << "Enter number of test this semester: "; cin >> numEx;
cin. ignore();
vector exGrades(numEx);
for (int32_t exIx = 0; exIx < numEx; ++exIx) {
cout << "Enter grade " << exIx << " as an integer: "; cin >> exGrades. at(exIx) ;
cin. ignore();
}
const auto fullName = firstName + " " + lastName;
cout << "Grade Report For " << fullName << ":\n";
const auto exAverage = getArrayAverage(exGrades); cout << "Your average is: " << exAverage << "\n";
// get GPA with newest course added:
const auto newLetterGrade = (exAverage); prevGrades. push_back(newLetterGrade);
const auto gpa = getArrayAverage(prevGrades);
cout << "Your latest GPA is: " << gpa << "\n";
return 0;
}
Please rewrite this program in pure C and without any C++ elements. You may use any compiler that you would like, but your program cannot have any C++ features. A few extra notes:1. If the C++ code uses dynamic allocation, then your C version also must use dynamic allocation.2. You may not change the primitive data types used (e. g., do not convert ints to doubles just so you can avoid dealing with the workaround for the function overloading). Once you finish writing your program, please write a brief report (no more than a few paragraphs) describing features in the above program that are in C++ and not in C and the different work-arounds you had to come up with in order to achieve the same functionality. Please feel free to elaborate on the aspects of the C program that were difficult to implement.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 23:00
Which factor is the most important when choosing a website host? whether customers will make secure transactions the number of email accounts provided the purpose of the website the quality of the host control panel
Answers: 3
question
Computers and Technology, 23.06.2019 19:30
2. fluorine and chlorine molecules are blamed fora trapping the sun's energyob forming acid rainoc producing smogod destroying ozone molecules
Answers: 2
question
Computers and Technology, 24.06.2019 12:00
Match the function to its purpose. fast worth 50pts.
Answers: 1
question
Computers and Technology, 24.06.2019 23:30
Adrian has decided to subscribe for a new internet connection. he wants a high speed connection so that he can stream video content smoothly. which access technology would you advise adrian against using?
Answers: 1
You know the right answer?
Consider the following C++ program that makes use of many features that are unique to C++ and did no...
Questions
question
Arts, 25.01.2021 17:40
question
Social Studies, 25.01.2021 17:40
question
Mathematics, 25.01.2021 17:40
question
Social Studies, 25.01.2021 17:40
Questions on the website: 13722367