4 questions c++ codes

1) Write a c++ program that contains the following functions

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

a) A function that takes in an integer array of any size, and fills up the array with values taken from the user. (Your function should work for any size array, and should be tested with at least 3 arrays of different sizes)

b) Do the same as a) above, but get the values from a file instead. (Create a file that has input for at least 3 arrays of different sizes).

c) A function that takes in an array of any size, and returns the sum of all multiples of 5 in the array.

d) A function that takes in an array of any size and an integer key m. It should return the mth smallest element in the array. (m cannot be larger than the size of the array, and your array should be unsorted).

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

For example for an array containing 3 2 4 8 9 6, and m is 2, it should return the 2nd smallest number in the array which is 3

e) A function that takes in an array of any size and a key, and returns the number of passes it takes to find the key in the array or 0 if it’s not in the array. Use Binary Search

f) A function that takes in an array of any size and prints the content 4 per line. (Test this function with at least 3 arrays of different sizes)

Optional Question (Practice)

Write the definition of a function that takes in any array of any size, and an integer key, and returns the smallest value closest to they key if it is in the array, returns 0 otherwise (Use Binary Search)

Example

6, 11, 15, 24 29 35 49 61 75 83. is contained in an array, with a key of 49, the smallest value closest to 49 is 35, and your function returns that.

2) Write a C++ program that reads from a file the last name of an election candidate and the number of votes that they received, you program would then determine what percentage of vote each candidate received and the winner of the election. Use the concept of parallel arrays. Your program should contain the following functions

a) A function to read in the data from the file into the appropriate data structure

b) A function to calculate each candidates percentage of vote earned

c) A function to print out each candidate’s name, number of votes and percentage of total vote earned (Output should be formatted to look like the file, with a new header for vote percent)

d) A function that returns the name of the election winner.

Use appropriate function calls to test your program. Below is the content of the file. ignore the first line containing the headers if it makes it easier to write

Candidate Number of Votes

Lannister 350000

Stark 310000

Targaryen 397000

Baratheon 275000

Martell 280000

Greyjoy 205000

Mormont 415000

Tully 30000

(Feel free to adjust the numbers in the file)

there is two more questios in the attachments

In cases where the student leaves a question unanswered, X is recorded as the choice.
Perform the grading using the following grading system, for questions that are answered
correctly 5 points is awarded, for incorrect attempts, 2 points is awarded, and for
questions not answered, 0 point is awarded.
Have a function read in the input
Have a function perform the grading based on the grading system above
Have a function display what letter grade the student achieved using the system
90 – 100 A
80-89
B
70-79
C С
60-89 D
0-59
F
1. Write a C++ program containing the following functions (20 pts)
a. Function to take in 8 numbers from the user to fill an array
b. Function that takes in an array and determines if it is a palindrome or not. Output
appropriate message. A palindrome is anything that is the same forwards and
backwards. Ex. 53544535 is a palindrome.
c. Function that outputs every multiple of 3 in the array
d. Function that prints the array in reverse.
2
Make use of the appropriate function calls. (ALL WORKING CODE SHOULD BE DONE IN THE
FUNCTIONS). Only thing the main can contain, if it contains anything at all, is function calls and
declarations
2 Write a C++ program that contains the following functions; Use as many arrays as you need (30
pts)
a.
A function that reads input from a file that contains the test scores of students in the
Math department, with values ranging from 0-200, into an array of size 25. Use values
76, 98, 150, 145, 200, 46, 11, 100, 172, 38, 188, 199, 167, 175, 108, 99, 129, 149, 176,
190, 71, 35, 159, 8, 133 inside your file.
b.
a function to determine the number of students that fall into the following ranges
0-24,25 – 49,50 – 74, 75 – 99, 100 – 124, 125 – 149, 150 – 174, 175 – 200
c
C.
a function to output each range along with a statement showing the number of students
falling into that range
d.
Help the computer science professor at your school with grading a multiple choice test.
Each question has 5 choices (A, B, C, D, E). A file contains the correct answer to the 40
questions as its first entry and the choices made by the student as the next entry
ACCBDEBCACACADEBDABDEADBDCABDAB CBDEBEACD
AACBCEEBACADADBCDACDCXDDB CABBXBCADDBEAXD

Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER