Coding object oriented language

Department of Computer Science

 

Don't use plagiarized sources. Get Your Custom Essay on
Coding object oriented language
Just from $13/Page
Order Essay

CS 115-Assignment 3

 

Submit source files (.cpp)

 

Question 1 [10].  (Template) Design a generic function that returns a minimum element from an array. The function should have two parameters. One is the array of a generic type, and the other is the size of the array. Test the function with an array of int, double, and string values.

 

 

Question 2 [10]. Use pointers to write a function that finds the largest element in an array of integers. Use {6, 7, 9, 10, 15, 3, 99, -21} to test the function.

 

Question 3 [15].  A class Student can have three member variables: name, age, and an array of grades of two exams marks [5]. The grades can be integers (0-100), doubles (0.0-100.00) and characters (A-F, where F denotes grades less than 50). Write a class template to accommodate all five types of grades. The class template must have two constructors (no-arg constructor, and a constructor that takes 7 parameters: name, age and grades of 5 exams). Write a function to read an object from console, and another function to print the object to the console. Implement the class template by creating three objects with three different types (int, double and char) of grades, and printing the objects on the console.

 

Question 4 a) [8]. Write two overloaded functions that return the sum of values at even locations of an array with the following headers:

 

int sumOfEven(const int* array, int size);

double sumOfEven(const double* array, int size);

 

Write a test program that reads five integers or double values, invokes this function, and displays the sum of values at even locations.

 

Question 4 b) [7]. Consider the Student class as defined in Question 3 above with grades as integers. Create a vector (in unsorted order) of 5 objects of the class, and implement the sort function to sort the vector with respect to (i) name (ii) age variables in ascending order.

or

 

Question 4 b) [7]. Consider the Student class as defined in Question 3 above with grades as integers. Create a set that stores 5 objects of the class in ascending order with respect to (i) name (ii) age variables.

 

Page 1 of 1

 

Still struggling to complete your homework?
Get instant homework help from our expert academic writers!