Test 2
Student 1
Task 1. Vectors
To do: Create a multi-file application to accomplish the following task. A vector of integer elements is given. Create a function named EvenDouble which must double all elements of the vector with even values.
Note 1: The signature of the function must be as follows:
void EvenDouble (vector<int>& v)
Note 2: It is possible to do the task in different ways: you can create a new vector with the doubled even elements or you can print out the elements, by doubling those with even values.
Expected output:
Vector before task:
1 2 3 4 5 6 7 8 9 10
after task:
1 4 3 8 5 12 7 16 9 20
Hint: You can find similar solutions here: https://labs-org.ru/c-plus-plus5-eng/
Task 2. Pointers
To do: Create a multi-file application to accomplish the following task. An array of integers is given. Create a function named SwapMinMax that swaps the minimum and maximum values of its elements.
Note: The signature of the function must be as follows:
void SwapMinMax (int* array, int n)
n is a number of the array elements
Expected output:
Array before task:
6 4 3 8 5 12 7 16 9 20
Array after task:
6 4 20 8 5 12 7 16 9 3
Hint: You can find similar solutions here: https://labs-org.ru/c-plus-plus7-eng/
Task 3.
Classes
To do: Create a multi-file application to accomplish the following task.
Create a Triangle class to store the information about an equilateral triangle.
1) The class
should contain the following members:
— one data
member of type int (member sideLength_) with private access,
—two member
functions with public access: theу are set_length and get_perimeter.
2) Define two member functions and give them implementations: set_length function should set the member sideLength_ to a value. get_perimeter function should return calculated perimeter of an equilateral triangle (the formula is 3* sideLength_).
3) Create a Custom default constructor to have the initial value for sideLength_ (set it to 10).
4) Inside the main function create an object of the class and print out the information about this object.
Expected output:
Hint: You can find similar solutions here: https://labs-org.ru/c-plus-plus10-eng/The triangle’s length is: 10
The perimeter is: 30
Student 2
Task 1. Vectors
To do: Create a multi-file application to accomplish the following task. A vector of integer elements is given. Create a function named MaxMinVector which prints out maximum and minimum elements of the vector.
Note: The signature of the function must be as follows:
void MaxMinVector (vector<int>& v)
Expected output:
Vector before task:
1 2 12 4 5 6 3 8 9 3
result:
min = 1 max = 12
Hint: You can find similar solutions here: https://labs-org.ru/c-plus-plus5-eng/
Task 2. Pointers
To do: Create a multi-file application to accomplish the following task. An array of integers is given. Create a function named DoubleEven that doubles the array’s even elements.
Note: the signature of the function must be as follows:
void DoubleEven (int* array, int n)
n is a number of the array elements
Expected output:
Array before task:
6 4 3 8 5 12 7 11 9 7
Array after task:
12 8 3 16 5 24 7 11 9 7
Hint: You can find similar solutions here: https://labs-org.ru/c-plus-plus7-eng/
Task 3.
Classes
To do: Create a multi-file application to accomplish the following task.
Create a Triangle class to store the information about an equilateral triangle.
1) The class
should contain the following members:
— one data
member of type int (member sideLength_) with private access,
—two member
functions with public access: they are set_length and get_area.
2) Define two member functions and give them implementations: set_length function should set the member sideLength_ to a value; get_area function should return the area of an equilateral triangle:
the formula is S = (a2 * sqrt(3)) / 4 , where a is a sideLength_
* To calculate the square root, you should include the library and use sqrt(sideLength_) function (#include <cmath>)
3) Create a Custom default constructor to have the initial value for sideLength_ (set it to 3).
4) Inside the main function create an object of the class and print out the information about this object.
Expected output:
The triangle’s length is: 3
The area is: 3.89711431702997
Hint: You can find similar solutions here: https://labs-org.ru/c-plus-plus10-eng/
Student 3
Task 1. Vectors
To do: Create a multi-file application to accomplish the following task. A vector of integer elements is given. Create a function named MakePostive which multiplies all vector elements with negative values by -1 .
Note 1: The signature of the function must be as follows:
void MakePositive (vector<int>& v)
Note 2: It is possible to do the task in different ways: you can create a new vector with changed negative elements to positives or you can print out the elements, by multiplying those with negative values by -1.
Expected output:
Vector before task:
1 -2 3 4 5 -6 7 8 -9 10
after task:
1 2 3 4 5 6 7 8 9 10
Hint: You can find similar solutions here: https://labs-org.ru/c-plus-plus5-eng/
Task 2. Pointers
To do: Create a multi-file application to accomplish the following task. An array of integers is given. Create a function named PrintOddIndexes that prints out the array’s elements with odd indexes.
Note: The signature of the function must be as follows:
void PrintOddInexes (int* array, int n)
n is a number of the array elements
Expected output:
Array before task:
6 4 3 8 5 12 7 11 9 7
Result:
6 3 5 7 9
Hint: You can find a bit similar solutions here: https://labs-org.ru/c-plus-plus7-eng/
Task 3. Classes
To do: Create a multi-file application to accomplish the following task.
Create a Circle class to store the information about a circle.
1) The class
should contain the following members:
— one data
member of type int (member radiusLength_) with private access,
—two member
functions with public access: they are set_ radius and get_area.
2) Define two member functions and give them implementations: set_radius function should set the member radiusLength_ to a value; get_area function should return the area of a circle (the formula is 2 * 3.14 * radiusLength_).
3) Create a Custom default constructor to have the initial value for radiusLength_ (set it to 10).
4) Inside the main function create an object of the class and print out the information about this object.
Expected output:
The circle’s radius is: 10
The area is: 62.8
Hint: You can find similar solutions here: https://labs-org.ru/c-plus-plus10-eng/
Student 4
Task 1. Vectors
To do: Create a multi-file application to accomplish the following task. A vector of integer elements is given. Create a function named FindLess that calculates and returns the number of vector’s elements, which are less than entered number x.
Note: The signature of the function must be as follows:
int FindLess (vector<int>& v, int x)
Expected output:
Vector:
1 2 12 4 5 6 3 8 9 3
Enter number x, please:
>> 3
result: 2
Hint: You can find similar solutions here: https://labs-org.ru/c-plus-plus5-eng/
Task 2. Pointers
To do: Create a multi-file application to accomplish the following task. An array of integers is given. Create a function named PrintLocalMinumum that prints out the array’s elements which are local minimums (a local minimum is an element that is less than any of its neighbors: e.g. ... 5 2 7 ... => number 2 is a local minimum, because 2 < 5 and 2 < 7).
Note: The signature of the function must be as follows:
void PrintLocalMinimum (int* array, int n)
n is a number of the array elements
Expected output:
Array before task:
6 4 3 8 5 12 6 11 9 7
Result:
3 6
Hint: You can find similar solutions here: https://labs-org.ru/c-plus-plus7-eng/
Task 3. Classes
To do: Create a multi-file application to accomplish the following task.
Create a Sphere class to store the information about a sphere.
1) The class
should contain the following members:
— one data
member of type int (member radiusLength_) with private access,
—two member
functions with public access: they are set_ radius and get_volume.
2) Define two member functions and give them implementatons: set_radius function should set the member radiusLength_ to a value; get_volume function should return the volume of a sphere (the formula is
(4/3) * 3.14 * radiusLength_3
To have a result of 4/3 as a real number you should use explicit conversion : (float)4/3
3) Create a Custom default constructor to have the initial value for radiusLength_ (set it to 10).
4) Inside the main function create an object of the class and print out the information about this object.
Expected output:
The sphere’s radius is: 10
The volume is: 4186.666666666667
Hint: You can find similar solutions here: https://labs-org.ru/c-plus-plus10-eng/
Student 5
Task 1. Vectors
To do: Create a multi-file application to accomplish the following task. A vector of integer elements is given. Create a function named EvenDouble which must double all the elements of the vector with even values.
Note 1: The signature of the function must be as follows:
void EvenDouble (vector<int>& v)
Note 2: It is possible to do the task in different ways: you can create a new vector with the doubled even elements or you can print out the elements, by doubling those with even values.
Expected output:
Vector before task:
1 2 3 4 5 6 7 8 9 10
after task:
1 4 3 8 5 12 7 16 9 20
Hint: You can find similar solutions here: https://labs-org.ru/c-plus-plus5-eng/
Task 2. Pointers
To do: Create a multi-file application to accomplish the following task. An array of integers is given. Create a function named DoubleEven that doubles the array’s even elements.
Note: the signature of the function must be as follows:
void DoubleEven (int* array, int n)
n is a number of the array elements
Expected output:
Array before task:
6 4 3 8 5 12 7 11 9 7
Array after task:
12 8 3 16 5 24 7 11 9 7
Hint: You can find similar solutions here: https://labs-org.ru/c-plus-plus7-eng/
Task 3. Classes
To do: Create a multi-file application to accomplish the following task.
Create a Circle class to store the information about a circle.
1) The class
should contain the following members:
— one data
member of type int (member radiusLength_) with private access,
—two member
functions with public access: the functions set_ radius and get_area.
2) Define two member functions and give them implementations: set_radius function should set the member radiusLength_ to a value; get_area function should return the area of a circle (the formula is 2*3.14*radiusLength_).
3) Create a Custom default constructor to have the initial value for radiusLength_ (set it to 10).
4) Inside the main function create an object of the class and print out the information about this object.
Expected output:
The circle’s radius is: 10
The area is: 62.8
Hint: You can find a bit similar solutions here: https://labs-org.ru/c-plus-plus10-eng/
Student 6
Task 1. Vectors
To do: Create a multi-file application to accomplish the following task. A vector of integer elements is given. Create a function named MaxMinVector which prints out maximum and minimum elements of the vector.
Note: the signature of the function must be as follows:
void MaxMinVector (vector<int>& v)
Expected output:
Vector before task:
1 2 12 4 5 6 3 8 9 3
result: 1 12
Hint: You can find a bit similar solutions here: https://labs-org.ru/c-plus-plus5-eng/
Task 2. Pointers
To do: Create a multi-file application to accomplish the following task. An array of integers is given. Create a function named PrintOddIndexes that prints out the array’s elements with odd indexes.
Note: the signature of the function must be as follows:
void PrintOddInexes (int* array, int n)
n is a number of the array elements
Expected output:
Array before task:
6 4 3 8 5 12 7 11 9 7
Result:
6 3 5 7 9
Hint: You can find a bit similar solutions here: https://labs-org.ru/c-plus-plus7-eng/
Task 3. Classes
To do: Create a multi-file application to accomplish the following task.
Create a Triangle class to store the information about an equilateral triangle.
1) The class
should contain the following members:
— one data
member of type int (member sideLength_) with private access,
—two member
functions with public access: the functions set_length and get_perimeter.
2) Define two member functions and give them implementations: set_length function should set the member sideLength_ to a value; get_perimeter function should return the perimeter of an equilateral triangle (the formula is 3* sideLength_).
3) Create a Custom default constructor to have the initial value for sideLength_ (set it to 10).
4) Inside the main function create an object of the class and print out the information about this object.
Expected output:
The triangle’s length is: 10
The perimeter is: 30
Hint: You can find a bit similar solutions here: https://labs-org.ru/c-plus-plus10-eng/
Student 7
Task 1. Vectors
To do: Create a multi-file application to accomplish the following task. A vector of integer elements is given. Create a function named FindLess that calculates and returns the number of vectors elements, which are less than entered number x.
Note: the signature of the function must be as follows:
int FindLess (vector<int>& v, int x)
Expected output:
Vector:
1 2 12 4 5 6 3 8 9 3
Enter number x, please:
>> 3
result: 2
Hint: You can find a bit similar solutions here: https://labs-org.ru/c-plus-plus5-eng/
Task 2. Pointers
To do: Create a multi-file application to accomplish the following task. An array of integers is given. Create a function named SwapMinMax that swaps the minimum and maximum values of its elements.
Note : the signature of the function must be as follows:
void SwapMinMax (int* array, int n)
n is a number of the array elements
Expected output:
Array before task:
6 4 3 8 5 12 7 16 9 20
Array after task:
6 4 20 8 5 12 7 16 9 3
Hint: You can find a bit similar solutions here: https://labs-org.ru/c-plus-plus7-eng/
Task 3. Classes
To do: Create a multi-file application to accomplish the following task.
Create a Triangle class to store the information about an equilateral triangle.
1) The class
should contain the following members:
— one data
member of type int (member sideLength_) with private access,
— and two
member functions with public access: the functions set_length and get_area.
2) Define two member functions: set_length function should set the member sideLength_ to a value; get_area function should return the area of an equilateral triangle:
the formula is S = (a2 * sqrt(3)) / 4 , where a is a sideLength_
* To calculate the square root, you should include the library and use sqrt(sideLength_) function (#include <cmath>)
3) Create a Custom default constructor to have the initial value for sideLength_ (set it to 3).
4) Inside the main function create an object of the class and print out the information about this object.
Expected output:
The triangle’s length is: 3
The area is: 3.89711431702997
Hint: You can find a bit similar solutions here: https://labs-org.ru/c-plus-plus10-eng/