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, 21.06.2019 22:00
Business professionals of america, and future business leaders of america – phi beta lambda are both open to business students at which levels? check all that apply. elementary school middle school high school college
Answers: 1
question
Computers and Technology, 22.06.2019 03:10
This program reads a file called 'test.txt'. you are required to write two functions that build a wordlist out of all of the words found in the file and print all of the unique words found in the file. remove punctuations using 'string.punctuation' and 'strip()' before adding words to the wordlist. write a function build_wordlist() that takes a 'file pointer' as an argument and reads the contents, builds the wordlist after removing punctuations, and then returns the wordlist. another function find_unique() will take this wordlist as a parameter and return another wordlist comprising of all unique words found in the wordlist. example: contents of 'test.txt': test file another line in the test file output: ['another', 'file', 'in', 'line', 'test', 'the']
Answers: 1
question
Computers and Technology, 22.06.2019 13:30
Asoftware company hired ray, a college graduate to work in their development team. ray is assigned to work in the coding phase of a project. what happens during the coding phase of a software development project? a. the customer receives a working model of the software. b. developers convert the program design into code. c. developers gather requirements directly from the stakeholders. d. testing teams check the product for quality.
Answers: 1
question
Computers and Technology, 24.06.2019 15:30
Python. primary u.s. interstate highways are numbered 1-99. odd numbers (like the 5 or 95) go north/south, and evens (like the 10 or 90) go east/west. auxiliary highways are numbered 100-999, and service the primary highway indicated by the rightmost two digits. thus, the 405 services the 5, and the 290 services the 90. given a highway number, indicate whether it is a primary or auxiliary highway. if auxiliary, indicate what primary highway it serves. also indicate if the (primary) highway runs north/south or east/west.
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
Mathematics, 28.09.2019 07:10
Questions on the website: 13722363