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 06:50
Type the correct answer in the box. spell all words correctly. which view of report creation allows you to customize the report before the database program creates it? creating a report in allows you to customize the report before the database program creates it. pl asap
Answers: 1
question
Computers and Technology, 23.06.2019 02:30
Which component acts as a platform on which application software runs
Answers: 2
question
Computers and Technology, 23.06.2019 04:31
Cloud computing service providers manage different computing resources based on the services they offer. which resources do iaas and paas providers not manage? iaas providers do not manage the for the client, whereas paas providers usually do not manage the for their clients. iaas- storage server operating system network paas- applications interafce storage vertualiation
Answers: 2
question
Computers and Technology, 24.06.2019 11:00
Why is it uncommon for users to perform searches directly in database tables? a.)users are discouraged from interacting directly with tables because they might confuse tables with spreadsheets. b.) users are discouraged from interacting directly with tables because this may result in unintended changes to source data. c.)users do not have the technical skills required to perform searches directly in database tables. d.)users do not have the permissions required to perform searches directly in database tables.
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
Questions on the website: 13722367