Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Assignment 3

Note: Late homework assignments will not be accepted, unless you have a valid written excuse (medical,   etc.). You must do this assignment alone. No team work or "talking with your friends" will be accepted. No copying from the Internet. Cheating means zero. Here are a few extra instructions: Give meaningful names to your variables so we can easily know what each variable is used for in your program. Put comments in    your code (in English!) to explain WHAT your code is doing and also to explain HOW your program is doing it. Make sure all your code is properly indented (formatted). Your code should be beautiful to read. This assignment 3 contains two parts: Part 1 : Write programs in C++ to complete the following tasks:

Task 1

Find the largest element of a given array of integers {1, 10, 22, -3, 17, 6, 11, 21}. You should use loop

statement(s) to complete this task. Note: for this task, you can use iostream library only, other libraries are not allowed. Here is the author's sample output:

 

--- Task 1 ---

Original array: 1 10 22 -3 17 6 11 21

Largest element of the the array: 22

Task 2

Find and print all unique elements of a given array of integers nums = {1, 10, 22, 22, -3, 17, 10, 6, 5, 11, 21, 1}. You should use loop statement(s) to complete this task. You can declare other array if necessary. Note: for   this task, you can use iostream library only, other libraries are not allowed. (Can you complete it without using other arrays? Think aout it.) Here is the author's sample output:

 

--- Task 2 ---

Original array: 1 10 22 22 -3 17 10 6 5 11 21 1

Unique elements of the said array: 1 10 22 -3 17 6 5 11 21

Task 3

Change the case (lower to upper and upper to lower cases) of each character of a given string (str = "This is an Assignment3. Please Finish it Before DDL."). Once you change it, print it out. And then insert your

name at the position 23 of the updated string. Finally, you should print it out. Tips: string library is allowed. Here is the author's sample output:


--- Task 3 ---

Original string:

This is an Assignment3. Please Finish it Before DDL.

After changed string:

tHIS IS AN aSSIGNMENT3. pLEASE fINISH IT bEFORE ddl.



After insert your name:

tHIS IS AN aSSIGNMENT3.He jing pLEASE fINISH IT bEFORE ddl.


Task 4

Given an integer array {1, 10, 22, 22, -3, 17, 10, 6, 5, 11, 21, 1}. Please sort it in ascending order and display it. You should use loop statement(s) to complete this task. Note: for this task, you can use iostream library only, other libraries are not allowed.

Task 5

Practice vector by following intructions. Tips: https://en.cppreference.com/w/cpp/container/vector

1. create a vector stores integer values named v with initial values {2, 4, 6, 8, 10}

2. output the vector's length

3. output all the elements of this vector

 

4. resize the vector to 8 and output all the elements of this vector

5. add an element 12 to the end of this vector and output all the elements

of this vector

6. insert an element 14 at the index 7 and output all the elements of this

vector

7. remove the last element and output all the elements of this vector

8. print out the value at the index 3

9. change the vaule of the element at the index 3 to 100 and output the

elements of this vector

10. clear the vector v and checks whether the vector is empty or not, if

it is empty, output " Yes, it is empty."

otherwise, output " No, it is not empty."

Task 6

Please define a sturct named Staff which contains four variables inside of it: an interger namedid, an

integer named age, a double named wage, and a string named name. Declare a Staff variable and assign some values for it. And display its information. Here is the author's sample output:


--- Task 6 ---

ID: 18

Age: 20

Wage: 108.

Name: Alita


Part 2 :Complete the Assignment03-Part2_0123456789.docx:

Submission

For each task, you should create a single cpp file following the format

Assignment3_q0123456789_task_x.cpp. You should replace q0123456789 with your student ID number and x to 1, 2, 3, 4, 5, 6 respectively. And compress these cpp files and Assignment03-

Part2_0123456789.docx into a zip file and rename it Assignment3_q0123456789.zip and upload to iSpace before deadline. (replace q0123456789 with your student ID number) Files list in the zip:


Assignment3_q0123456789_task_1.cpp

Assignment3_q0123456789_task_2.cpp

Assignment3_q0123456789_task_3.cpp

Assignment3_q0123456789_task_4.cpp


 

Assignment3_q0123456789_task_5.cpp

Assignment3_q0123456789_task_6.cpp

Assignment03-Part2_0123456789.docx

Deadline will be announced on iSpace.