Skip to main content
EDU-MMCS
You are currently using guest access (Log in)

CS211 C++, Programming languages

  1. Home
  2. Courses
  3. Осенний семестр
  4. Фундаментальная информатика и ИТ
  5. CS211 C++ ENG
  6. Module 2. Object-oriented programming
  7. Test 2

Test 2

Completion requirements
Opened: Monday, 20 November 2023, 8:00 AM
Due: Thursday, 28 December 2023, 11:00 PM

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:

The triangle’s length is: 10

The perimeter is: 30

Hint: You can find similar solutions here: https://labs-org.ru/c-plus-plus10-eng/

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/


◄ Lesson # 10. Classes
Lesson # 11. Lists ►
Skip Navigation
Navigation
  • Home

    • Site pages

      • My courses

      • Tags

    • My courses

    • Courses

      • Осенний семестр

        • Прикладная математика и информатика

        • Фундаментальная информатика и ИТ

          • Compiler Development

          • CMVSM

          • АЗПК

          • Frontend

          • ТеорЯП

          • Ruby Eng

          • EngCA&OS

          • CS201e

          • Компиляторы - лекции

          • CS202

          • CS211 C++ ENG

            • General

            • Module 1. Introduction

            • Module 2. Object-oriented programming

              • AssignmentLesson # 9. Structures

              • AssignmentLesson # 10. Classes

              • AssignmentTest 2

              • AssignmentLesson # 11. Lists

            • Recursion

            • Topic 4

            • Topic 5

            • Topic 6

            • Topic 7

            • Topic 8

            • Topic 9

            • Topic 10

        • Математика, механика

        • Педагогическое образование

        • Магистратура

          • Разработка мобильных приложений и компьютерных игр

        • Аспирантура

        • Вечернее отделение

        • Другое

      • Весенний семестр

        • Прикладная математика и информатика

        • Фундаментальная информатика и ИТ

        • Математика, механика

        • Педагогическое образование

        • Магистратура

          • Разработка мобильных приложений и компьютерных игр

        • Аспирантура

        • Вечернее отделение

        • Другое

      • Воскресная компьютерная школа

        • Пользователь компьютера плюс

        • Пользователь прикладных программ

        • Программирование I ступень

        • Программирование II ступень

        • Программирование III ступень

        • Архив

      • Воскресная математическая школа

        • Открытое тестирование РНОМЦ и мехмата ЮФУ - 2025

        • Олимпиадная математическая школа

        • Повышение квалификации

        • Доступная математика

        • Лаборатория математического онлайн-образования мех...

        • Осенняя универсиада

        • Научно-практическая конференция

        • ВМШ

          • ВМШ - 24

        • Летняя олимпиадная математическая школа РНОМЦ и ме...

      • Государственная итоговая аттестация

      • Дополнительное образование

      • Олимпиады

      • Видеолекции

      • Разное

      • Архив курсов

      • Заочная школа мехмата ЮФУ

Contact site support
You are currently using guest access (Log in)
CS211 C++ ENG
Data retention summary
Get the mobile app Яндекс.Метрика